diff options
| author | Jakob Kaivo <jkk@ung.org> | 2019-02-11 20:11:57 -0500 |
|---|---|---|
| committer | Jakob Kaivo <jkk@ung.org> | 2019-02-11 20:11:57 -0500 |
| commit | 14959826beb8697b16acc97a589785ffaf4d7824 (patch) | |
| tree | 87d1e8b8d82aeb99c256045db91cac7af29405cd /src/stdlib | |
| parent | 17cac403fc65f73c841a9cecc517bec595f01217 (diff) | |
make notes about ignoring and restoring signals
Diffstat (limited to 'src/stdlib')
| -rw-r--r-- | src/stdlib/system.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/stdlib/system.c b/src/stdlib/system.c index ac0d54d5..612a9570 100644 --- a/src/stdlib/system.c +++ b/src/stdlib/system.c @@ -20,6 +20,9 @@ int system(const char * string) return 0; } + /* ignore SIGINT and SIGQUIT */ + /* block SIGCHLD */ + pid = fork(); if (pid < 0) { /* errno comes from fork() */ @@ -27,13 +30,19 @@ int system(const char * string) } if (pid == 0) { + /* restore signal handlers */ execl("/bin/sh", "sh", "-c", string, (char *)0); - _exit(1); + _exit(127); } if (waitpid(pid, &status, 0) == -1) { errno = ECHILD; - return -1; + status = -1; + } + + /* restore signal handlers */ + if (WIFSIGNALED(status)) { + } return status; |
