pty problems w/ Unixware

Kevin Steves stevesk at sweden.hp.com
Fri Feb 2 08:50:42 EST 2001


On Thu, 1 Feb 2001, Damien Miller wrote:
: This looks like another candidate for Kevin's mysignal() stuff. Kevin?

the mysignal() idea is from markus.  i implemented it with a change that
checks whether we're re-installing the prior handler, and if so noops.

i've been using this patch for the protocol 2 SIGCHLD problem on hp-ux.  
a s/signal/mysignal/ would be a next step.

Index: misc.c
===================================================================
RCS file: /var/cvs/openssh/misc.c,v
retrieving revision 1.1
diff -u -r1.1 misc.c
--- misc.c	2001/01/22 05:34:42	1.1
+++ misc.c	2001/01/23 16:55:27
@@ -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"
 
@@ -94,4 +95,26 @@
 		*s += strspn(*s + 1, WHITESPACE) + 1;
 
 	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
 }
Index: misc.h
===================================================================
RCS file: /var/cvs/openssh/misc.h,v
retrieving revision 1.1
diff -u -r1.1 misc.h
--- misc.h	2001/01/22 05:34:42	1.1
+++ misc.h	2001/01/23 16:55:27
@@ -17,3 +17,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);
Index: serverloop.c
===================================================================
RCS file: /var/cvs/openssh/serverloop.c,v
retrieving revision 1.37
diff -u -r1.37 serverloop.c
--- serverloop.c	2001/01/22 05:34:43	1.37
+++ serverloop.c	2001/01/23 16:55:33
@@ -111,7 +111,7 @@
 	int save_errno = errno;
 	debug("Received SIGCHLD.");
 	child_terminated = 1;
-	signal(SIGCHLD, sigchld_handler2);
+	mysignal(SIGCHLD, sigchld_handler2);
 	errno = save_errno;
 }
 
@@ -645,7 +645,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();






More information about the openssh-unix-dev mailing list