diff options
author | John Kohl <jtkohl@mit.edu> | 1988-12-05 11:31:25 +0000 |
---|---|---|
committer | John Kohl <jtkohl@mit.edu> | 1988-12-05 11:31:25 +0000 |
commit | 74cb5b047a32a547e406e7a698b72f65277d7f06 (patch) | |
tree | 066d0bcabda169d97d3b75264c63795a1ee6dd5d | |
parent | 4bbe91fedcef7c94045cfd679834c40064d74eff (diff) |
handle SIGINT, TERM, HUP
-rw-r--r-- | clients/zaway/zaway.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/clients/zaway/zaway.c b/clients/zaway/zaway.c index 3409a1b..796c9c6 100644 --- a/clients/zaway/zaway.c +++ b/clients/zaway/zaway.c @@ -6,7 +6,7 @@ * $Source$ * $Author$ * - * Copyright (c) 1987 by the Massachusetts Institute of Technology. + * Copyright (c) 1987,1988 by the Massachusetts Institute of Technology. * For copying and distribution information, see the file * "mit-copyright.h". */ @@ -17,6 +17,7 @@ #include <pwd.h> #include <string.h> +#include <signal.h> #ifndef lint static char rcsid_zaway_c[] = "$Header$"; @@ -28,6 +29,14 @@ static char rcsid_zaway_c[] = "$Header$"; extern char *getenv(), *malloc(); extern uid_t getuid(); +#ifdef ULTRIX30 +void cleanup(); +#else +int cleanup(); +#endif + +u_short port; + main(argc,argv) int argc; char *argv[]; @@ -35,7 +44,6 @@ main(argc,argv) FILE *fp; ZNotice_t notice; ZSubscription_t sub; - u_short port; int retval; struct passwd *pw; char awayfile[BUFSIZ],*ptr,*msg[2],*envptr; @@ -77,6 +85,10 @@ main(argc,argv) exit(1); } + (void) signal(SIGINT, cleanup); + (void) signal(SIGTERM, cleanup); + (void) signal(SIGHUP, cleanup); + if ((retval = ZSubscribeTo(&sub,1,port)) != ZERR_NONE) { com_err(argv[0],retval,"while subscribing"); exit(1); @@ -169,3 +181,14 @@ char *find_message(notice,fp) return (ptr); } + +#ifdef ULTRIX30 +void +#else +int +#endif +cleanup() +{ + ZCancelSubscriptions(port); + exit(1); +} |