summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2013-09-01 19:59:54 +0000
committerjilles <jilles@FreeBSD.org>2013-09-01 19:59:54 +0000
commit73eea4eee65f7ee7912a17673042e3d6bf781f84 (patch)
tree2741e2e8a1227f8c2433271f28422f617453ca6c
parent112102f8f6823fc3c0802cf6d5da73d112fa9693 (diff)
downloadFreeBSD-src-73eea4eee65f7ee7912a17673042e3d6bf781f84.zip
FreeBSD-src-73eea4eee65f7ee7912a17673042e3d6bf781f84.tar.gz
system(): Restore behaviour for SIGINT and SIGQUIT.
As mentioned in r16117 and the book "Advanced Programming in the Unix Environment" by W. Richard Stevens, we should ignore SIGINT and SIGQUIT before forking, since it is not guaranteed that the parent process starts running soon enough. To avoid calling sigaction() in the vforked child, instead block SIGINT and SIGQUIT before vfork() and keep the sigaction() to ignore after vfork(). The FreeBSD kernel discards ignored signals, even if they are blocked; therefore, it is not necessary to unblock SIGINT and SIGQUIT earlier.
-rw-r--r--lib/libc/stdlib/system.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/libc/stdlib/system.c b/lib/libc/stdlib/system.c
index 64a5447..e018e6f 100644
--- a/lib/libc/stdlib/system.c
+++ b/lib/libc/stdlib/system.c
@@ -59,6 +59,8 @@ __system(const char *command)
(void)sigemptyset(&newsigblock);
(void)sigaddset(&newsigblock, SIGCHLD);
+ (void)sigaddset(&newsigblock, SIGINT);
+ (void)sigaddset(&newsigblock, SIGQUIT);
(void)_sigprocmask(SIG_BLOCK, &newsigblock, &oldsigblock);
switch(pid = vfork()) {
case -1: /* error */
OpenPOWER on IntegriCloud