summaryrefslogtreecommitdiffstats
path: root/src/ninja.cc
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2011-12-01 20:55:18 (GMT)
committerPeter Collingbourne <peter@pcc.me.uk>2012-02-04 21:46:12 (GMT)
commit44f58aeca923d6e3001636f8c0d24a6d513d8ea2 (patch)
tree9507856d2854532510f8a38fdc11c5f19f21554a /src/ninja.cc
parent85ff781fa30fff63c01ccd30faaad39d766e1505 (diff)
downloadNinja-44f58aeca923d6e3001636f8c0d24a6d513d8ea2.zip
Ninja-44f58aeca923d6e3001636f8c0d24a6d513d8ea2.tar.gz
Ninja-44f58aeca923d6e3001636f8c0d24a6d513d8ea2.tar.bz2
If a command fails, wait for all running commands to terminate before we do
Previously, if a command fails, the fate of the other child processes running in parallel was inadequately controlled. On POSIX platforms, the processes were orphaned. Normally they would run to completion, but were liable to being killed by a SIGPIPE. On Windows, the child processes would terminate with the parent. The cleanup-on-interrupt patch caused the SubprocessSet and Builder destructors to clean up after themselves by killing any running child processes and deleting their output files, making the behaviour more predictable and consistent across platforms. If the build is interrupted by the user, this is correct behaviour. But in the case where the build is stopped by a failed command, this would be inconsistent with user expectations. In the latter case, we now let any remaining child processes run to completion before leaving the main loop in Builder::Build.
Diffstat (limited to 'src/ninja.cc')
-rw-r--r--src/ninja.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/ninja.cc b/src/ninja.cc
index 1822e54..6cc2276 100644
--- a/src/ninja.cc
+++ b/src/ninja.cc
@@ -13,6 +13,7 @@
// limitations under the License.
#include <errno.h>
+#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
@@ -613,9 +614,10 @@ int main(int argc, char** argv) {
if (*end != 0)
Fatal("-k parameter not numeric; did you mean -k0?");
- // We want to go until N jobs fail, which means we should ignore
- // the first N-1 that fail and then stop.
- globals.config.swallow_failures = value - 1;
+ // We want to go until N jobs fail, which means we should allow
+ // N failures and then stop. For N <= 0, INT_MAX is close enough
+ // to infinite for most sane builds.
+ globals.config.failures_allowed = value > 0 ? value : INT_MAX;
break;
}
case 'n':