lib9: restore SIGCHLD handler in rfork

R=rsc
http://codereview.appspot.com/4436071
diff --git a/src/lib9/rfork.c b/src/lib9/rfork.c
index a14d11e..bbd08b0 100644
--- a/src/lib9/rfork.c
+++ b/src/lib9/rfork.c
@@ -18,6 +18,9 @@
 	int n;
 	char buf[128], *q;
 	extern char **environ;
+	struct sigaction oldchld;
+
+	memset(&oldchld, 0, sizeof oldchld);
 
 	if((flags&(RFPROC|RFFDG|RFMEM)) == (RFPROC|RFFDG)){
 		/* check other flags before we commit */
@@ -28,12 +31,7 @@
 			return -1;
 		}
 		if(flags&RFNOWAIT){
-			/*
-			 * BUG - should put the signal handler back after we
-			 * finish, but I just don't care.  If a program calls with
-			 * NOWAIT once, they're not likely to want child notes
-			 * after that.
-			 */
+			sigaction(SIGCHLD, nil, &oldchld);
 			signal(SIGCHLD, nop);
 			if(pipe(p) < 0)
 				return -1;
@@ -97,6 +95,7 @@
 					close(p[1]);
 				}
 			}
+			sigaction(SIGCHLD, &oldchld, nil);
 		}
 		if(pid != 0)
 			return pid;