summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorKevin Steves <stevesk@pobox.com>2001-02-04 13:20:36 +0000
committerKevin Steves <stevesk@pobox.com>2001-02-04 13:20:36 +0000
commitb6e773acc9f27118b215a892ba704123a6df7b72 (patch)
tree083542bf79b817ac9790232c14d7a508f0d6ecc0 /misc.c
parentb797b92237276b87bb758648d61ef71579befc5b (diff)
- (stevesk) add mysignal() wrapper and use it for the protocol 2
SIGCHLD handler.
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/misc.c b/misc.c
index 2d7b2fa6..a073c905 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 @@ 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
+}