Merge "Wait for children to exit in makeparallel" am: 9b1a185029
am: c08e57ce4d
Change-Id: I2bc1fe1b9834ab56575db0c2e6fa96b968550382
This commit is contained in:
@@ -357,18 +357,23 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
static pid_t pid;
|
static pid_t pid;
|
||||||
|
|
||||||
// Set up signal handlers to forward SIGTERM to child
|
// Set up signal handlers to forward SIGTERM to child.
|
||||||
// Assume that all other signals are sent to the entire process group
|
// Assume that all other signals are sent to the entire process group,
|
||||||
|
// and that we'll wait for our child to exit instead of handling them.
|
||||||
struct sigaction action = {};
|
struct sigaction action = {};
|
||||||
action.sa_flags = SA_SIGINFO | SA_RESTART,
|
action.sa_flags = SA_RESTART;
|
||||||
action.sa_sigaction = [](int signal, siginfo_t*, void*) {
|
action.sa_handler = [](int signal) {
|
||||||
if (pid > 0) {
|
if (signal == SIGTERM && pid > 0) {
|
||||||
kill(pid, signal);
|
kill(pid, signal);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
if (!ret) ret = sigaction(SIGHUP, &action, NULL);
|
||||||
|
if (!ret) ret = sigaction(SIGINT, &action, NULL);
|
||||||
|
if (!ret) ret = sigaction(SIGQUIT, &action, NULL);
|
||||||
if (!ret) ret = sigaction(SIGTERM, &action, NULL);
|
if (!ret) ret = sigaction(SIGTERM, &action, NULL);
|
||||||
|
if (!ret) ret = sigaction(SIGALRM, &action, NULL);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
error(errno, errno, "sigaction failed");
|
error(errno, errno, "sigaction failed");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user