diff options
Diffstat (limited to 'src/subprocess-posix.cc')
-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_; |