From 14959826beb8697b16acc97a589785ffaf4d7824 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Mon, 11 Feb 2019 20:11:57 -0500 Subject: make notes about ignoring and restoring signals --- src/stdlib/system.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src') 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; -- cgit v1.2.1