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.
This commit is contained in:
Jilles Tjoelker 2013-09-01 19:59:54 +00:00
parent c672165162
commit 865ca149dc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=255129

View file

@ -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 */