diff options
author | Lukacs Berki <lberki@google.com> | 2016-08-19 14:40:20 +0000 |
---|---|---|
committer | Yue Gan <yueg@google.com> | 2016-08-22 08:11:02 +0000 |
commit | 3d97e2245dbbd34d3428218e745a3770c6d1c0ee (patch) | |
tree | a93a61ffc98339b363dea6d06cfa7e35530c870e /src/main/java/com/google/devtools/build/lib/standalone | |
parent | f5cf200376dd7ebd201138283b2585a6e0cab260 (diff) |
Implement timeouts on Windows.
Makes #1664 much less acute.
--
MOS_MIGRATED_REVID=130750731
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/standalone')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategy.java | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategy.java b/src/main/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategy.java index 6c5df1b864..04da210372 100644 --- a/src/main/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategy.java +++ b/src/main/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategy.java @@ -77,11 +77,11 @@ public class StandaloneSpawnStrategy implements SpawnActionContext { .getEventBus() .post(ActionStatusMessage.runningStrategy(spawn.getResourceOwner(), "standalone")); - int timeout = -1; + int timeoutSeconds = -1; String timeoutStr = spawn.getExecutionInfo().get("timeout"); if (timeoutStr != null) { try { - timeout = Integer.parseInt(timeoutStr); + timeoutSeconds = Integer.parseInt(timeoutStr); } catch (NumberFormatException e) { throw new UserExecException("could not parse timeout: ", e); } @@ -97,7 +97,7 @@ public class StandaloneSpawnStrategy implements SpawnActionContext { // Disable it for now to make the setup easier and to avoid further PATH hacks. // Ideally we should have a native implementation of process-wrapper for Windows. args.add(processWrapper.getPathString()); - args.add(Integer.toString(timeout)); + args.add(Integer.toString(timeoutSeconds)); args.add("5"); /* kill delay: give some time to print stacktraces and whatnot. */ // TODO(bazel-team): use process-wrapper redirection so we don't have to @@ -109,7 +109,8 @@ public class StandaloneSpawnStrategy implements SpawnActionContext { String cwd = executor.getExecRoot().getPathString(); Command cmd = new Command(args.toArray(new String[]{}), - locallyDeterminedEnv(spawn.getEnvironment()), new File(cwd)); + locallyDeterminedEnv(spawn.getEnvironment()), new File(cwd), + OS.getCurrent() == OS.WINDOWS && timeoutSeconds >= 0 ? timeoutSeconds * 1000 : -1); FileOutErr outErr = actionExecutionContext.getFileOutErr(); try { @@ -121,7 +122,8 @@ public class StandaloneSpawnStrategy implements SpawnActionContext { /*killSubprocessOnInterrupt*/ true); } catch (AbnormalTerminationException e) { TerminationStatus status = e.getResult().getTerminationStatus(); - boolean timedOut = !status.exited() && (status.getTerminatingSignal() == 14 /* SIGALRM */); + boolean timedOut = !status.exited() && ( + status.timedout() || status.getTerminatingSignal() == 14 /* SIGALRM */); String message = CommandFailureUtils.describeCommandFailure( verboseFailures, spawn.getArguments(), spawn.getEnvironment(), cwd); |