Revert to default sigchld handler after forking, don't exit

on error writing to the signal_pipe.

--HG--
branch : channel-fix
extra : convert_revision : 1d7826f7be07ee728abb42b6a9826d8ea7142fbe
This commit is contained in:
Matt Johnston 2007-02-12 13:32:30 +00:00
parent 519ff96bcd
commit 7c1d4d1903

View File

@ -126,16 +126,12 @@ static void sesssigchild_handler(int UNUSED(dummy)) {
/* Make sure that the main select() loop wakes up */ /* Make sure that the main select() loop wakes up */
while (1) { while (1) {
/* EAGAIN means the pipe's full, so don't need to write anything */ /* isserver is just a random byte to write. We can't do anything
/* isserver is just a random byte to write */ about an error so should just ignore it */
if (write(ses.signal_pipe[1], &ses.isserver, 1) == 1 if (write(ses.signal_pipe[1], &ses.isserver, 1) == 1
|| errno == EAGAIN) { || errno != EINTR) {
break; break;
} }
if (errno == EINTR) {
continue;
}
dropbear_exit("error writing signal pipe");
} }
} }
@ -662,6 +658,12 @@ static int noptycommand(struct Channel *channel, struct ChanSess *chansess) {
if (!pid) { if (!pid) {
/* child */ /* 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 */ /* redirect stdin/stdout */
#define FDIN 0 #define FDIN 0
#define FDOUT 1 #define FDOUT 1
@ -759,6 +761,12 @@ static int ptycommand(struct Channel *channel, struct ChanSess *chansess) {
if (pid == 0) { if (pid == 0) {
/* child */ /* 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 */ /* redirect stdin/stdout/stderr */
close(chansess->master); close(chansess->master);