From 6503964dad4555a9999c449dde6d499fa97a2f2e Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 23 May 2007 11:44:47 +0000 Subject: John Buddery: 23461: fix race setting up input multios --- Src/exec.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'Src') diff --git a/Src/exec.c b/Src/exec.c index 5aa3dba12..f711f3d30 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -1549,20 +1549,29 @@ closemn(struct multio **mfds, int fd) pid_t pid; struct timeval bgtime; + /* + * We need to block SIGCHLD in case the process + * we are spawning terminates before the job table + * is set up to handle it. + */ + child_block(); if ((pid = zfork(&bgtime))) { for (i = 0; i < mn->ct; i++) zclose(mn->fds[i]); zclose(mn->pipe); - if (pid == -1) { + if (pid == -1) { mfds[fd] = NULL; + child_unblock(); return; } mn->ct = 1; mn->fds[0] = fd; addproc(pid, NULL, 1, &bgtime); + child_unblock(); return; } /* pid == 0 */ + child_unblock(); closeallelse(mn); if (mn->rflag) { /* tee process */ -- cgit 1.4.1