From 0a4c67a874e7bce9e358c82489782c9e402a58a4 Mon Sep 17 00:00:00 2001 From: james <> Date: Mon, 10 Mar 2008 11:49:33 +0000 Subject: *** empty log message *** --- apps/clients.h | 9 +++++---- apps/expand.c | 6 +++++- apps/mainloop.c | 6 ++++-- apps/sympathy.c | 49 +++++++++++++++++++++++++++++-------------------- 4 files changed, 43 insertions(+), 27 deletions(-) (limited to 'apps') diff --git a/apps/clients.h b/apps/clients.h index 8a1625e..b2e669a 100644 --- a/apps/clients.h +++ b/apps/clients.h @@ -12,6 +12,9 @@ /* * $Log$ + * Revision 1.9 2008/03/10 11:49:32 james + * *** empty log message *** + * * Revision 1.8 2008/03/07 13:16:02 james * *** empty log message *** * @@ -41,16 +44,14 @@ #ifndef __CLIENTS_H__ #define __CLIENTS_H__ -typedef struct Client_struct -{ +typedef struct Client_struct { struct Client_struct *next; int initialized; Socket *s; int dead; } Client; -typedef struct -{ +typedef struct { Client *head; int n; } Clients; diff --git a/apps/expand.c b/apps/expand.c index f8f8d48..8b26d32 100644 --- a/apps/expand.c +++ b/apps/expand.c @@ -6,10 +6,14 @@ * */ -static char rcsid[] = "$Id$"; +static char rcsid[] = + "$Id$"; /* * $Log$ + * Revision 1.5 2008/03/10 11:49:32 james + * *** empty log message *** + * * Revision 1.4 2008/03/07 14:19:29 staffcvs * *** empty log message *** * diff --git a/apps/mainloop.c b/apps/mainloop.c index 15c30ed..74e456e 100644 --- a/apps/mainloop.c +++ b/apps/mainloop.c @@ -11,6 +11,9 @@ static char rcsid[] = /* * $Log$ + * Revision 1.29 2008/03/10 11:49:32 james + * *** empty log message *** + * * Revision 1.28 2008/03/07 13:56:39 james * *** empty log message *** * @@ -140,8 +143,7 @@ static char rcsid[] = #include "clients.h" -typedef struct -{ +typedef struct { int nclients; int lines; int baud; diff --git a/apps/sympathy.c b/apps/sympathy.c index ef120ec..94cd801 100644 --- a/apps/sympathy.c +++ b/apps/sympathy.c @@ -11,6 +11,9 @@ static char rcsid[] = /* * $Log$ + * Revision 1.41 2008/03/10 11:49:32 james + * *** empty log message *** + * * Revision 1.40 2008/03/07 14:16:44 james * *** empty log message *** * @@ -462,8 +465,8 @@ main (int argc, char *argv[]) ANSI *ansi = NULL; - int csnok_pipe[2] = { 0 }; - int csnok = 0; + int cs_pipe[2] = { 0 }; + int cs = 0; int oflags[128]; char *oargs[128]; @@ -568,10 +571,8 @@ main (int argc, char *argv[]) /* to find out the pid of the server, we use a pipe */ if (oflags['s'] && oflags['c']) { - if (!oflags['k']) { - csnok++; - pipe (csnok_pipe); - } + cs++; + pipe (cs_pipe); switch (pid = fork ()) { case 0: /* child becomes the server */ @@ -580,8 +581,7 @@ main (int argc, char *argv[]) oflags['N'] = 0; oflags['I'] = 0; - if (csnok) - close (csnok_pipe[0]); + close (cs_pipe[0]); break; case -1: fatal_moan ("fork failed"); @@ -604,16 +604,18 @@ main (int argc, char *argv[]) /* if there was no k argument we need to find the */ /* pid of the server process so that we can work out */ /* what the socket is called. The server tells us on */ - /* a pipe */ + /* a pipe. We do this even if k is specified to avoid */ + /* a race, the server writes to the pipe when the socket */ + /* is opened */ - if (csnok) { - close (csnok_pipe[1]); + close (cs_pipe[1]); - if (read (csnok_pipe[0], &pid, sizeof (pid)) != sizeof (pid)) - fatal_moan ("Failed to receive pid of server process"); + if (read (cs_pipe[0], &pid, sizeof (pid)) != sizeof (pid)) + fatal_moan ("Failed to receive pid of server process"); - close (csnok_pipe[0]); + close (cs_pipe[0]); + if (!oflags['k']) { oargs['k'] = mome ("/.sympathy/%s%d", hostname, pid); oflags['k']++; } @@ -680,11 +682,12 @@ main (int argc, char *argv[]) server_socket = socket_listen (oargs['k']); /* Tell our parent's parent what our pid is */ - if (csnok) { + /* and that we've opened the server socket */ + if (cs) { pid = getpid (); - write (csnok_pipe[1], &pid, sizeof (pid)); - close (csnok_pipe[1]); + write (cs_pipe[1], &pid, sizeof (pid)); + close (cs_pipe[1]); } if (!server_socket) @@ -792,7 +795,6 @@ main (int argc, char *argv[]) fatal_moan ("-I requires an arugment"); send_to_server (client_socket, oargs['I']); } else { - if (client_socket) ipc_msg_send_initialize (client_socket); @@ -807,13 +809,20 @@ main (int argc, char *argv[]) ansi = ansi_new_from_terminal (terminal_open (0, 1), oflags['u'] ? 0 : 1); ansi->reset (ansi, NULL); - if (ansi->set_title) + + } + + if (ansi->set_title) { + if (oflags['c'] && oargs['k']) { ansi->set_title (ansi, oargs['k']); + } else if ((ctx->t) && (ctx->t->name)) { + ansi->set_title (ansi, ctx->t->name); + } } + } } - ctx->v = vt102_new (&size); ctx->h = history_new (history); -- cgit v1.2.3