diff options
author | Nico Weber <nicolasweber@gmx.de> | 2015-11-12 00:51:29 (GMT) |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2015-11-12 00:51:29 (GMT) |
commit | 935788e2c019706a0f04b1b759c6751f1c2ee3c7 (patch) | |
tree | 511e4decbf8522c6776de721b84e2f4eb515aa5d /src/subprocess-posix.cc | |
parent | 381e56a34c1c0bdf58889041d052b45ea53a09c7 (diff) | |
parent | 23de4b25e9285d24cfa21fbed5acd105492866d8 (diff) | |
download | Ninja-935788e2c019706a0f04b1b759c6751f1c2ee3c7.zip Ninja-935788e2c019706a0f04b1b759c6751f1c2ee3c7.tar.gz Ninja-935788e2c019706a0f04b1b759c6751f1c2ee3c7.tar.bz2 |
Merge pull request #964 from nicolasdespres/sighup
Cleanup build on SIGHUP.
Diffstat (limited to 'src/subprocess-posix.cc')
-rw-r--r-- | src/subprocess-posix.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/subprocess-posix.cc b/src/subprocess-posix.cc index f3baec2..2ddc709 100644 --- a/src/subprocess-posix.cc +++ b/src/subprocess-posix.cc @@ -64,6 +64,8 @@ bool Subprocess::Start(SubprocessSet* set, const string& command) { break; if (sigaction(SIGTERM, &set->old_term_act_, 0) < 0) break; + if (sigaction(SIGHUP, &set->old_hup_act_, 0) < 0) + break; if (sigprocmask(SIG_SETMASK, &set->old_mask_, 0) < 0) break; @@ -136,7 +138,8 @@ ExitStatus Subprocess::Finish() { if (exit == 0) return ExitSuccess; } else if (WIFSIGNALED(status)) { - if (WTERMSIG(status) == SIGINT || WTERMSIG(status) == SIGTERM) + if (WTERMSIG(status) == SIGINT || WTERMSIG(status) == SIGTERM + || WTERMSIG(status) == SIGHUP) return ExitInterrupted; } return ExitFailure; @@ -167,6 +170,8 @@ void SubprocessSet::HandlePendingInterruption() { interrupted_ = SIGINT; else if (sigismember(&pending, SIGTERM)) interrupted_ = SIGTERM; + else if (sigismember(&pending, SIGHUP)) + interrupted_ = SIGHUP; } SubprocessSet::SubprocessSet() { @@ -174,6 +179,7 @@ SubprocessSet::SubprocessSet() { sigemptyset(&set); sigaddset(&set, SIGINT); sigaddset(&set, SIGTERM); + sigaddset(&set, SIGHUP); if (sigprocmask(SIG_BLOCK, &set, &old_mask_) < 0) Fatal("sigprocmask: %s", strerror(errno)); @@ -184,6 +190,8 @@ SubprocessSet::SubprocessSet() { Fatal("sigaction: %s", strerror(errno)); if (sigaction(SIGTERM, &act, &old_term_act_) < 0) Fatal("sigaction: %s", strerror(errno)); + if (sigaction(SIGHUP, &act, &old_hup_act_) < 0) + Fatal("sigaction: %s", strerror(errno)); } SubprocessSet::~SubprocessSet() { @@ -193,6 +201,8 @@ SubprocessSet::~SubprocessSet() { Fatal("sigaction: %s", strerror(errno)); if (sigaction(SIGTERM, &old_term_act_, 0) < 0) Fatal("sigaction: %s", strerror(errno)); + if (sigaction(SIGHUP, &old_hup_act_, 0) < 0) + Fatal("sigaction: %s", strerror(errno)); if (sigprocmask(SIG_SETMASK, &old_mask_, 0) < 0) Fatal("sigprocmask: %s", strerror(errno)); } |