From: Theodore Tso Date: Sat, 29 Apr 1995 04:35:37 +0000 (+0000) Subject: Use Posix sigaction() instead of signal() to set signal handlers. X-Git-Tag: krb5-1.0-beta5~96 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=913b16c5efda182a7a149cf2f422a2cfe711d760;p=krb5.git Use Posix sigaction() instead of signal() to set signal handlers. This allows us not to worry about System V signal semantics. Make the code use POSIX_SIGNALS by default. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5657 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/kadmin.v4/server/ChangeLog b/src/kadmin.v4/server/ChangeLog index c57b30e1f..98ba9f8ac 100644 --- a/src/kadmin.v4/server/ChangeLog +++ b/src/kadmin.v4/server/ChangeLog @@ -1,3 +1,10 @@ +Sat Apr 29 00:34:01 1995 Theodore Y. Ts'o + + * admin_server.c (kadm_listen): Use Posix sigaction() instead of + signal() to set signal handlers. This allows us not to + worry about System V signal semantics. Make the code use + POSIX_SIGNALS by default. + Fri Apr 28 18:08:05 1995 Mark Eichin * Makefile.in (KLIB): put KRB4_LIB inside KLIB. diff --git a/src/kadmin.v4/server/admin_server.c b/src/kadmin.v4/server/admin_server.c index 45425722e..b04b3835a 100644 --- a/src/kadmin.v4/server/admin_server.c +++ b/src/kadmin.v4/server/admin_server.c @@ -19,6 +19,9 @@ #include #endif +/* define it for now */ +#define POSIX_SIGNALS + #include #include #include @@ -44,6 +47,12 @@ #include "com_err.h" #include "kadm_server.h" +#ifdef POSIX_SIGTYPE +#define SIGNAL_RETURN return +#else +#define SIGNAL_RETURN return(0) +#endif + /* Almost all procs and such need this, so it is global */ admin_params prm; /* The command line parameters struct */ @@ -190,11 +199,7 @@ doexit(sig) int sig; { exit_now = 1; -#ifdef POSIX_SIGNALS - return; -#else /* !POSIX */ - return(0); -#endif /* POSIX */ + SIGNAL_RETURN; } unsigned pidarraysize = 0; @@ -217,14 +222,29 @@ kadm_listen() void process_client(), kill_children(); int pid; krb5_sigtype do_child(); - - (void) signal(SIGINT, doexit); - (void) signal(SIGTERM, doexit); - (void) signal(SIGHUP, doexit); - (void) signal(SIGQUIT, doexit); - (void) signal(SIGPIPE, SIG_IGN); /* get errors on write() */ - (void) signal(SIGALRM, doexit); - (void) signal(SIGCHLD, do_child); +#ifdef POSIX_SIGNALS + struct sigaction new_act; + + new_act.sa_handler = doexit; + sigemptyset(&new_act.sa_mask); + sigaction(SIGINT, &new_act, 0); + sigaction(SIGTERM, &new_act, 0); + sigaction(SIGHUP, &new_act, 0); + sigaction(SIGQUIT, &new_act, 0); + sigaction(SIGALRM, &new_act, 0); + new_act.sa_handler = SIG_IGN; + sigaction(SIGPIPE, &new_act, 0); + new_act.sa_handler = do_child; + sigaction(SIGCHLD, &new_act, 0); +#else + signal(SIGINT, doexit); + signal(SIGTERM, doexit); + signal(SIGHUP, doexit); + signal(SIGQUIT, doexit); + signal(SIGPIPE, SIG_IGN); /* get errors on write() */ + signal(SIGALRM, doexit); + signal(SIGCHLD, do_child); +#endif if ((admin_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) return KADM_NO_SOCK; @@ -461,11 +481,7 @@ do_child(sig) pid, status.w_termsig, status.w_coredump, status.w_retcode); #endif -#ifdef POSIX_SIGNALS - return; -#else /* !POSIX */ - return(0); -#endif /* POSIX */ + SIGNAL_RETURN; } unknown_child = pid; #ifdef WAIT_USES_INT @@ -477,11 +493,7 @@ do_child(sig) pid, status.w_termsig, status.w_coredump, status.w_retcode); #endif -#ifdef POSIX_SIGNALS - return; -#else /* !POSIX */ - return(0); -#endif /* POSIX */ + SIGNAL_RETURN; } #ifndef DEBUG