summaryrefslogtreecommitdiff
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
parentb797b92237276b87bb758648d61ef71579befc5b (diff)
- (stevesk) add mysignal() wrapper and use it for the protocol 2
SIGCHLD handler.
-rw-r--r--ChangeLog2
-rw-r--r--misc.c23
-rw-r--r--misc.h4
-rw-r--r--serverloop.c4
4 files changed, 31 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 8c5391ce7..9ab110c61 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -29,6 +29,8 @@
29 - (djm) Update several bits for new optional reverse lookup stuff. I 29 - (djm) Update several bits for new optional reverse lookup stuff. I
30 think I got them all. 30 think I got them all.
31 - (djm) Makefile.in fixes 31 - (djm) Makefile.in fixes
32 - (stevesk) add mysignal() wrapper and use it for the protocol 2
33 SIGCHLD handler.
32 34
3320010103 3520010103
34 - (bal) Cygwin clean up by Corinna Vinschen <vinschen@redhat.com> 36 - (bal) Cygwin clean up by Corinna Vinschen <vinschen@redhat.com>
diff --git a/misc.c b/misc.c
index 2d7b2fa60..a073c9052 100644
--- a/misc.c
+++ b/misc.c
@@ -27,6 +27,7 @@
27#include "includes.h" 27#include "includes.h"
28RCSID("$OpenBSD: util.c,v 1.6 2000/10/27 07:32:19 markus Exp $"); 28RCSID("$OpenBSD: util.c,v 1.6 2000/10/27 07:32:19 markus Exp $");
29 29
30#include "misc.h"
30#include "ssh.h" 31#include "ssh.h"
31#include "log.h" 32#include "log.h"
32 33
@@ -95,3 +96,25 @@ strdelim(char **s)
95 96
96 return (old); 97 return (old);
97} 98}
99
100mysig_t
101mysignal(int sig, mysig_t act)
102{
103#ifdef HAVE_SIGACTION
104 struct sigaction sa, osa;
105
106 if (sigaction(sig, 0, &osa) == -1)
107 return (mysig_t) -1;
108 if (osa.sa_handler != act) {
109 memset(&sa, 0, sizeof sa);
110 sigemptyset(&sa.sa_mask);
111 sa.sa_flags = 0;
112 sa.sa_handler = act;
113 if (sigaction(sig, &sa, 0) == -1)
114 return (mysig_t) -1;
115 }
116 return (osa.sa_handler);
117#else
118 return (signal(sig, act));
119#endif
120}
diff --git a/misc.h b/misc.h
index 16370425a..1dd038960 100644
--- a/misc.h
+++ b/misc.h
@@ -19,3 +19,7 @@ char *strdelim(char **s);
19 19
20/* set filedescriptor to non-blocking */ 20/* set filedescriptor to non-blocking */
21void set_nonblock(int fd); 21void set_nonblock(int fd);
22
23/* wrapper for signal interface */
24typedef void (*mysig_t)(int);
25mysig_t mysignal(int sig, mysig_t act);
diff --git a/serverloop.c b/serverloop.c
index bdac6a0d2..353733d31 100644
--- a/serverloop.c
+++ b/serverloop.c
@@ -110,7 +110,7 @@ sigchld_handler2(int sig)
110 int save_errno = errno; 110 int save_errno = errno;
111 debug("Received SIGCHLD."); 111 debug("Received SIGCHLD.");
112 child_terminated = 1; 112 child_terminated = 1;
113 signal(SIGCHLD, sigchld_handler2); 113 mysignal(SIGCHLD, sigchld_handler2);
114 errno = save_errno; 114 errno = save_errno;
115} 115}
116 116
@@ -639,7 +639,7 @@ server_loop2(void)
639 639
640 debug("Entering interactive session for SSH2."); 640 debug("Entering interactive session for SSH2.");
641 641
642 signal(SIGCHLD, sigchld_handler2); 642 mysignal(SIGCHLD, sigchld_handler2);
643 signal(SIGPIPE, SIG_IGN); 643 signal(SIGPIPE, SIG_IGN);
644 child_terminated = 0; 644 child_terminated = 0;
645 connection_in = packet_get_connection_in(); 645 connection_in = packet_get_connection_in();