Modified: trunk/base/src/pextlib1.0/system.c (147223 => 147224)
--- trunk/base/src/pextlib1.0/system.c 2016-03-31 15:33:52 UTC (rev 147223)
+++ trunk/base/src/pextlib1.0/system.c 2016-03-31 15:53:21 UTC (rev 147224)
@@ -56,6 +56,7 @@
#include <unistd.h>
#include <limits.h>
#include <errno.h>
+#include <signal.h>
#include "system.h"
#include "sip_copy_proc.h"
@@ -187,6 +188,22 @@
}
}
+ /*
+ * Ignore SIGINT and SIGQUIT, just like system(3)
+ *
+ * system(3) also blocks SIGCHLD during the execution of the program.
+ * However, that would make our wait(2) call more complicated. As we are
+ * not relying on delivery of SIGCHLD anywhere else, we just do not change
+ * the handling here at all.
+ */
+ struct sigaction sa, old_sa_int, old_sa_quit;
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_handler = SIG_IGN;
+ sigemptyset(&sa.sa_mask);
+ sigaction(SIGINT, &sa, &old_sa_int);
+ sigaction(SIGQUIT, &sa, &old_sa_quit);
+
+ /* fork a new process */
pid = fork();
switch (pid) {
case -1: /* error */
@@ -229,6 +246,10 @@
}
}
+ /* restore original signal handling */
+ sigaction(SIGINT, &old_sa_int, NULL);
+ sigaction(SIGQUIT, &old_sa_quit, NULL);
+
/* XXX ugly string constants */
if (sandbox) {
args[0] = "sandbox-exec";
@@ -342,6 +363,10 @@
}
}
+ /* restore original signal handling */
+ sigaction(SIGINT, &old_sa_int, NULL);
+ sigaction(SIGQUIT, &old_sa_quit, NULL);
+
if (odup) {
/* Cleanup. */
close(fdset[0]);