From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Sun, 24 Apr 2011 23:36:17 -0400 To: 9fans@9fans.net Message-ID: <84c61fe2a739f0786622f2e27e7a1b82@ladd.quanstro.net> In-Reply-To: <2afb8aa9b8f443793d7bf20463b78c1c@ladd.quanstro.net> References: <86wrijennb.fsf@cmarib.ramside> <20110424171741.D5865B827@mail.bitblocks.com> <20110425020029.GA29551@dinah> <2afb8aa9b8f443793d7bf20463b78c1c@ladd.quanstro.net> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] Different results for the same rc script when using listen1 Topicbox-Message-UUID: d48686e4-ead6-11e9-9d60-3106f5b1d025 ; hg diff rfork.c > hmm. is that right? it's wait3/wait4 that's failing. it shouldn't > be necesary to catch SIGCHLD for wait to work. but maybe > it is i take it back. i'd forgotten how quirky unix is these days. here's the solution. not rc's fault. recompile lib9 and listen1: diff -r 5caa04977471 src/lib9/rfork.c --- a/src/lib9/rfork.c Sun Dec 27 09:22:43 2009 -0800 +++ b/src/lib9/rfork.c Sun Apr 24 23:33:52 2011 -0400 @@ -18,7 +18,9 @@ int n; char buf[128], *q; extern char **environ; + void *oldchild; + oldchild = nil; if((flags&(RFPROC|RFFDG|RFMEM)) == (RFPROC|RFFDG)){ /* check other flags before we commit */ flags &= ~(RFPROC|RFFDG|RFENVG); @@ -34,7 +36,7 @@ * NOWAIT once, they're not likely to want child notes * after that. */ - signal(SIGCHLD, nop); + oldchild = signal(SIGCHLD, nop); if(pipe(p) < 0) return -1; } @@ -81,7 +83,10 @@ * Child - fork a new child whose wait message can't * get back to the parent because we're going to exit! */ - signal(SIGCHLD, SIG_IGN); + if(oldchild == nil) + oldchild = signal(SIGCHLD, SIG_IGN); + else + signal(SIGCHLD, SIG_IGN); close(p[0]); pid = fork(); if(pid){ @@ -95,6 +100,8 @@ }else{ /* Child child - close pipe. */ close(p[1]); + if(oldchild) + signal(SIGCHLD, oldchild); } } } - erik