| tlib9: restore SIGCHLD handler in rfork - plan9port - [fork] Plan 9 from user s… | |
| git clone git://src.adamsgaard.dk/plan9port | |
| Log | |
| Files | |
| Refs | |
| README | |
| LICENSE | |
| --- | |
| commit 333482548d6b93fede42dc1944d3bb692098a211 | |
| parent f444695a2ab0237262b25c590c2dd9309f225128 | |
| Author: Russ Cox <[email protected]> | |
| Date: Sun, 1 May 2011 15:38:18 -0400 | |
| lib9: restore SIGCHLD handler in rfork | |
| R=rsc | |
| http://codereview.appspot.com/4436071 | |
| Diffstat: | |
| M src/lib9/rfork.c | 11 +++++------ | |
| 1 file changed, 5 insertions(+), 6 deletions(-) | |
| --- | |
| diff --git a/src/lib9/rfork.c b/src/lib9/rfork.c | |
| t@@ -18,6 +18,9 @@ p9rfork(int flags) | |
| 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 */ | |
| t@@ -28,12 +31,7 @@ p9rfork(int flags) | |
| 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 … | |
| - * 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; | |
| t@@ -97,6 +95,7 @@ p9rfork(int flags) | |
| close(p[1]); | |
| } | |
| } | |
| + sigaction(SIGCHLD, &oldchld, nil); | |
| } | |
| if(pid != 0) | |
| return pid; |