diff options
author | Taiju Tsuiki <tzik@google.com> | 2015-01-09 22:19:11 (GMT) |
---|---|---|
committer | tzik <tzik@google.com> | 2015-01-19 00:55:51 (GMT) |
commit | f2bfbda312ac92de3656ff3ae284a7ec82e59e74 (patch) | |
tree | 05e7a48c451ea44ca73b85f3cf7109b25f109221 /src | |
parent | da94924bddd2554957067c06fb10ff2a8eb58824 (diff) | |
download | Ninja-f2bfbda312ac92de3656ff3ae284a7ec82e59e74.zip Ninja-f2bfbda312ac92de3656ff3ae284a7ec82e59e74.tar.gz Ninja-f2bfbda312ac92de3656ff3ae284a7ec82e59e74.tar.bz2 |
Check pending SIGINT after ppoll/pselect
ppoll/pselect prioritizes file descriptor events over
a signal delivery. So a flood of events prevents ninja
from reacting keyboard interruption by the user.
This CL adds a check for pending keyboard interruptions after
file descriptor events.
Diffstat (limited to 'src')
-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_; |