aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorjames <>2008-03-03 06:04:18 +0000
committerjames <>2008-03-03 06:04:18 +0000
commit800cb4bdfb56dcd606216788fb023fcc23fb69bf (patch)
tree50fe942cb0a48d40b83672de5a7055d762cb0dc2 /apps
parent2924f520651924e11c83fceda9c0f771065e1d07 (diff)
downloadsympathy-800cb4bdfb56dcd606216788fb023fcc23fb69bf.tar.gz
sympathy-800cb4bdfb56dcd606216788fb023fcc23fb69bf.tar.bz2
sympathy-800cb4bdfb56dcd606216788fb023fcc23fb69bf.zip
*** empty log message ***
Diffstat (limited to 'apps')
-rw-r--r--apps/sympathy.c44
-rw-r--r--apps/usage.c19
2 files changed, 52 insertions, 11 deletions
diff --git a/apps/sympathy.c b/apps/sympathy.c
index 91ed6da..ff3a8bc 100644
--- a/apps/sympathy.c
+++ b/apps/sympathy.c
@@ -11,6 +11,9 @@ static char rcsid[] =
/*
* $Log$
+ * Revision 1.31 2008/03/03 06:04:18 james
+ * *** empty log message ***
+ *
* Revision 1.30 2008/03/02 10:38:18 james
* *** empty log message ***
*
@@ -114,6 +117,9 @@ static char rcsid[] =
#include <strings.h>
#include <malloc.h>
#include <fcntl.h>
+#include <sys/resource.h>
+#include <sys/wait.h>
+
#include "mainloop.h"
@@ -154,6 +160,20 @@ fatal_moan (char *fmt, ...)
exit (1);
}
+static void sigchld(int dummy)
+{
+int status;
+ wait3(&status,WNOHANG,NULL);
+}
+
+/*Dispell zombies, from for example log compression*/
+void garlic(void) {
+struct sigaction sa;
+
+ sa.sa_handler = sigchld;
+ sa.sa_flags = SA_RESTART;
+ sigaction (SIGCHLD, &sa, NULL);
+}
char *
teedious_snprintf (char *fmt, va_list ap)
@@ -401,11 +421,13 @@ main (int argc, char *argv[])
int history = 200;
int pid;
+ char *pid_file=NULL;
+
get_hostname ();
memset (oflags, 0, sizeof (oflags));
memset (oargs, 0, sizeof (oargs));
- while ((c = getopt (argc, argv, "vw:utscr:lKHd:pb:fL:Fk:n:")) != EOF) {
+ while ((c = getopt (argc, argv, "RP:vw:utscr:lKHd:pb:fL:Fk:n:")) != EOF) {
switch (c) {
case ':':
case 'h':
@@ -514,6 +536,8 @@ main (int argc, char *argv[])
oflags['b'] = 0;
oflags['f'] = 0;
oflags['L'] = 0;
+ oflags['R'] = 0;
+ oflags['P'] = 0;
oflags['n'] = 0;
oflags['w'] = 0;
@@ -544,8 +568,8 @@ main (int argc, char *argv[])
fatal_moan ("-c requires a socket to be specified with -s or -k or -r");
if ((oflags['p'] || oflags['d'] || oflags['K'] || oflags['b'] || oflags['f']
- || oflags['L']) && oflags['c'])
- fatal_moan ("-c or -r are incompatible with -p, -d, -K, -b, -f or -L");
+ || oflags['L'] || oflags['R'] || oflags['P']) && oflags['c'])
+ fatal_moan ("-c or -r are incompatible with -p, -d, -K, -b, -f, -R, -P or -L");
if (oflags['t'] || oflags['s']) {
if (!oflags['p'] && !oflags['d'])
@@ -608,9 +632,18 @@ main (int argc, char *argv[])
}
if (oflags['s'] || oflags['t']) {
+ if (oflags['P']) {
+ FILE *fp;
+ pid_file=oargs['P'];
+ fp=fopen(pid_file,"w");
+ if (fp) {
+ fprintf(fp,"%d",getpid());
+ fclose(fp);
+ }
+ }
if (oflags['L']) {
- log = file_log_new (oargs['L']);
+ log = file_log_new (oargs['L'], oflags['R']);
if (!log)
fatal_moan ("unable to access log file %s", oargs['L']);
}
@@ -720,6 +753,9 @@ main (int argc, char *argv[])
if (client_socket)
socket_free (client_socket);
+ if (pid_file)
+ unlink(pid_file);
+
if (!oflags['H'])
printf ("you have now exited sympathy\n");
return 0;
diff --git a/apps/usage.c b/apps/usage.c
index 307511d..1aed8f0 100644
--- a/apps/usage.c
+++ b/apps/usage.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.18 2008/03/03 06:04:18 james
+ * *** empty log message ***
+ *
* Revision 1.17 2008/02/28 16:57:51 james
* *** empty log message ***
*
@@ -71,12 +74,12 @@ usage (void)
{
fprintf (stderr, "Usage:\n"
- "sympathy -t [-K] [-d serialdev|-p] [-b baud] [-f] [-L log]\n"
- " [-w WxH] [-u]\n"
- "sympathy -s [-K] [-d serialdev|-p] [-b baud] [-f] [-L log] [-k skt]\n"
- " [-n hlines] [-w WxH] [-F]\n"
- "sympathy [-s -c] [-K] [-d serialdev|-p] [-b baud] [-f] [-L log] [-k skt]\n"
- " [-n hlines] [-w WxH] [-u]\n"
+ "sympathy -t [-K] [-d serialdev|-p] [-b baud] [-f] [-L log] [-w WxH]\n"
+ " [-F] [-P pidfile] [-u]\n"
+ "sympathy -s [-K] [-d serialdev|-p] [-b baud] [-f] [-L log] [-w WxH]\n"
+ " [-F] [-P pidfile] [-n hlines] [-k skt]\n"
+ "sympathy [-s -c] [-K] [-d serialdev|-p] [-b baud] [-f] [-L log] [-w WxH]\n"
+ " [-F] [-P pidfile] [-u] [-n hlines] [-k skt]\n"
"sympathy -c [-H] [-u] -k skt\n"
"sympathy -r id [-H] [-u]\n"
"sympathy {-l|-ls}\n"
@@ -119,8 +122,10 @@ usage (void)
" -H instead of connecting the user's terminal to the session\n"
" emit HTML of the current state of the screen on stdout\n"
" -L log log activity on the device to the file log\n"
- " -n hlines the number of lines of history to store in the\n"
+ " -n nlines the number of lines of history to store in the\n"
" server, that are replayed on connexion\n"
+ " -P pidfile write the pid of the server/terminal process to pidfile\n"
+ " -R rotate logile specified with -L option\n"
" -u don't emit utf-8 try to use ISO-2202 to the local terminal\n"
" -w W[xH] start session with a screen of size W by H. 0<W<=132,\n"
" 0<H<24, default 80 by 24\n");