- (stevesk) add mysignal() wrapper and use it for the protocol 2
SIGCHLD handler.
diff --git a/ChangeLog b/ChangeLog
index 8c5391c..9ab110c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
diff --git a/misc.c b/misc.c
index 2d7b2fa..a073c90 100644
--- a/misc.c
+++ b/misc.c
@@ -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 @@
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
+}
diff --git a/misc.h b/misc.h
index 1637042..1dd0389 100644
--- a/misc.h
+++ b/misc.h
@@ -19,3 +19,7 @@
/* 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 bdac6a0..353733d 100644
--- a/serverloop.c
+++ b/serverloop.c
@@ -110,7 +110,7 @@
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 @@
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();