diff svr-chansession.c @ 427:5df05d0a5366 channel-fix

Revert to default sigchld handler after forking, don't exit on error writing to the signal_pipe.
author Matt Johnston <matt@ucc.asn.au>
date Mon, 12 Feb 2007 13:32:30 +0000
parents b2b67cfcd66e
children 1009980436c2 4317be8b7cf9
line wrap: on
line diff
--- a/svr-chansession.c	Mon Feb 12 10:39:34 2007 +0000
+++ b/svr-chansession.c	Mon Feb 12 13:32:30 2007 +0000
@@ -126,16 +126,12 @@
 		
 		/* Make sure that the main select() loop wakes up */
 		while (1) {
-			/* EAGAIN means the pipe's full, so don't need to write anything */
-			/* isserver is just a random byte to write */
-			if (write(ses.signal_pipe[1], &ses.isserver, 1) == 1 
-					|| errno == EAGAIN) {
+			/* isserver is just a random byte to write. We can't do anything
+			about an error so should just ignore it */
+			if (write(ses.signal_pipe[1], &ses.isserver, 1) == 1
+					|| errno != EINTR) {
 				break;
 			}
-			if (errno == EINTR) {
-				continue;
-			}
-			dropbear_exit("error writing signal pipe");
 		}
 	}
 
@@ -662,6 +658,12 @@
 	if (!pid) {
 		/* child */
 
+		TRACE(("back to normal sigchld"))
+		/* Revert to normal sigchld handling */
+		if (signal(SIGCHLD, SIG_DFL) == SIG_ERR) {
+			dropbear_exit("signal() error");
+		}
+
 		/* redirect stdin/stdout */
 #define FDIN 0
 #define FDOUT 1
@@ -759,6 +761,12 @@
 	if (pid == 0) {
 		/* child */
 		
+		TRACE(("back to normal sigchld"))
+		/* Revert to normal sigchld handling */
+		if (signal(SIGCHLD, SIG_DFL) == SIG_ERR) {
+			dropbear_exit("signal() error");
+		}
+		
 		/* redirect stdin/stdout/stderr */
 		close(chansess->master);