summaryrefslogtreecommitdiff
path: root/tools/makeparallel/makeparallel.cpp
diff options
context:
space:
mode:
author Dan Willemsen <dwillemsen@google.com> 2017-02-21 16:27:23 -0800
committer Dan Willemsen <dwillemsen@google.com> 2017-02-21 17:53:35 -0800
commitf0e2986cbf1e3e5d8f201a462047021d38b6cc25 (patch)
tree31a141f594fc61f809702276b2a706493aa24bd1 /tools/makeparallel/makeparallel.cpp
parenta7d4e0cd73e9eda41630baf69938bbddffbc530a (diff)
Wait for children to exit in makeparallel
This is a partial revert to the last makeparallel change, since now we were being killed by the signal before waiting for our child to exit. So instead of not installing the handlers, only pass the signal along if it's a SIGTERM. Bug: 35214134 Test: Ensure that we're still only getting one signal for SIGINT Test: Ctrl-C, ensure that all the soong_ui lines are before the make error line. Change-Id: I26fff9483a3abfd79ceb5a9ea47e3f7572d9e923
Diffstat (limited to 'tools/makeparallel/makeparallel.cpp')
-rw-r--r--tools/makeparallel/makeparallel.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/tools/makeparallel/makeparallel.cpp b/tools/makeparallel/makeparallel.cpp
index a99b2867ae..66babdf13d 100644
--- a/tools/makeparallel/makeparallel.cpp
+++ b/tools/makeparallel/makeparallel.cpp
@@ -357,18 +357,23 @@ int main(int argc, char* argv[]) {
static pid_t pid;
- // Set up signal handlers to forward SIGTERM to child
- // Assume that all other signals are sent to the entire process group
+ // Set up signal handlers to forward SIGTERM to child.
+ // 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 = {};
- action.sa_flags = SA_SIGINFO | SA_RESTART,
- action.sa_sigaction = [](int signal, siginfo_t*, void*) {
- if (pid > 0) {
+ action.sa_flags = SA_RESTART;
+ action.sa_handler = [](int signal) {
+ if (signal == SIGTERM && pid > 0) {
kill(pid, signal);
}
};
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(SIGALRM, &action, NULL);
if (ret < 0) {
error(errno, errno, "sigaction failed");
}