diff options
author | Kevin Steves <stevesk@pobox.com> | 2001-02-04 13:20:36 +0000 |
---|---|---|
committer | Kevin Steves <stevesk@pobox.com> | 2001-02-04 13:20:36 +0000 |
commit | b6e773acc9f27118b215a892ba704123a6df7b72 (patch) | |
tree | 083542bf79b817ac9790232c14d7a508f0d6ecc0 | |
parent | b797b92237276b87bb758648d61ef71579befc5b (diff) |
- (stevesk) add mysignal() wrapper and use it for the protocol 2
SIGCHLD handler.
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | misc.c | 23 | ||||
-rw-r--r-- | misc.h | 4 | ||||
-rw-r--r-- | serverloop.c | 4 |
4 files changed, 31 insertions, 2 deletions
@@ -29,6 +29,8 @@ - (djm) Update several bits for new optional reverse lookup stuff. I think I got them all. - (djm) Makefile.in fixes + - (stevesk) add mysignal() wrapper and use it for the protocol 2 + SIGCHLD handler. 20010103 - (bal) Cygwin clean up by Corinna Vinschen <vinschen@redhat.com> @@ -27,6 +27,7 @@ #include "includes.h" RCSID("$OpenBSD: util.c,v 1.6 2000/10/27 07:32:19 markus Exp $"); +#include "misc.h" #include "ssh.h" #include "log.h" @@ -95,3 +96,25 @@ strdelim(char **s) return (old); } + +mysig_t +mysignal(int sig, mysig_t act) +{ +#ifdef HAVE_SIGACTION + struct sigaction sa, osa; + + if (sigaction(sig, 0, &osa) == -1) + return (mysig_t) -1; + if (osa.sa_handler != act) { + memset(&sa, 0, sizeof sa); + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + sa.sa_handler = act; + if (sigaction(sig, &sa, 0) == -1) + return (mysig_t) -1; + } + return (osa.sa_handler); +#else + return (signal(sig, act)); +#endif +} @@ -19,3 +19,7 @@ char *strdelim(char **s); /* set filedescriptor to non-blocking */ void set_nonblock(int fd); + +/* wrapper for signal interface */ +typedef void (*mysig_t)(int); +mysig_t mysignal(int sig, mysig_t act); diff --git a/serverloop.c b/serverloop.c index bdac6a0d..353733d3 100644 --- a/serverloop.c +++ b/serverloop.c @@ -110,7 +110,7 @@ sigchld_handler2(int sig) int save_errno = errno; debug("Received SIGCHLD."); child_terminated = 1; - signal(SIGCHLD, sigchld_handler2); + mysignal(SIGCHLD, sigchld_handler2); errno = save_errno; } @@ -639,7 +639,7 @@ server_loop2(void) debug("Entering interactive session for SSH2."); - signal(SIGCHLD, sigchld_handler2); + mysignal(SIGCHLD, sigchld_handler2); signal(SIGPIPE, SIG_IGN); child_terminated = 0; connection_in = packet_get_connection_in(); |