diff options
author | Nico Weber <nicolasweber@gmx.de> | 2015-01-24 06:18:34 (GMT) |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2015-01-24 06:18:34 (GMT) |
commit | 62458b6f19dd134d2a4a38ff81e368c8b7e5605d (patch) | |
tree | 57641c121d380b720f38df52736dc21f77e6d584 | |
parent | 3ed37c7476b59d618bda86369479939358ab81bc (diff) | |
parent | f2bfbda312ac92de3656ff3ae284a7ec82e59e74 (diff) | |
download | Ninja-62458b6f19dd134d2a4a38ff81e368c8b7e5605d.zip Ninja-62458b6f19dd134d2a4a38ff81e368c8b7e5605d.tar.gz Ninja-62458b6f19dd134d2a4a38ff81e368c8b7e5605d.tar.bz2 |
Merge pull request #897 from tzik/pending
Check pending SIGINT after ppoll/pselect
-rw-r--r-- | src/subprocess-posix.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/subprocess-posix.cc b/src/subprocess-posix.cc index 743e406..40c9ae1 100644 --- a/src/subprocess-posix.cc +++ b/src/subprocess-posix.cc @@ -25,9 +25,24 @@ #include "util.h" +namespace { + +bool HasPendingInterruption() { + sigset_t pending; + sigemptyset(&pending); + if (sigpending(&pending) == -1) { + perror("ninja: sigpending"); + return false; + } + return sigismember(&pending, SIGINT); +} + +} // anonymous namespace + Subprocess::Subprocess(bool use_console) : fd_(-1), pid_(-1), use_console_(use_console) { } + Subprocess::~Subprocess() { if (fd_ >= 0) close(fd_); @@ -209,6 +224,9 @@ bool SubprocessSet::DoWork() { return interrupted_; } + if (HasPendingInterruption()) + return true; + nfds_t cur_nfd = 0; for (vector<Subprocess*>::iterator i = running_.begin(); i != running_.end(); ) { @@ -256,6 +274,9 @@ bool SubprocessSet::DoWork() { return interrupted_; } + if (HasPendingInterruption()) + return true; + for (vector<Subprocess*>::iterator i = running_.begin(); i != running_.end(); ) { int fd = (*i)->fd_; |