diff options
author | ulfjack <ulfjack@google.com> | 2017-06-08 05:56:29 -0400 |
---|---|---|
committer | John Cater <jcater@google.com> | 2017-06-08 10:53:10 -0400 |
commit | 7eadc73735d20dd27a20655d902e1456083d2649 (patch) | |
tree | 6856093ee689120891933c9400fdb414111616c2 /src/main/java | |
parent | da56606563ee9df438db93392f681bf2abb4ac97 (diff) |
Add some tests to the LocalSpawnRunner, and make some small tweaks
- Only manually check the timeout if the process wrapper is not used
- Set the timeout correctly; the process API uses milliseconds
- flush the error output stream after writing
- return SIGALRM as exit code for timeout cases
PiperOrigin-RevId: 158374246
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunner.java | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunner.java b/src/main/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunner.java index 7580a25a2c..215ae2ef14 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunner.java +++ b/src/main/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunner.java @@ -58,7 +58,7 @@ public final class LocalSpawnRunner implements SpawnRunner { private static final Joiner SPACE_JOINER = Joiner.on(' '); private static final String UNHANDLED_EXCEPTION_MSG = "Unhandled exception running a local spawn"; private static final int LOCAL_EXEC_ERROR = -1; - private static final int POSIX_TIMEOUT_EXIT_CODE = /*SIGNAL_BASE=*/128 + /*SIGWINCH=*/28; + private static final int POSIX_TIMEOUT_EXIT_CODE = /*SIGNAL_BASE=*/128 + /*SIGALRM=*/14; private final Logger logger; @@ -246,7 +246,7 @@ public final class LocalSpawnRunner implements SpawnRunner { cmdLine.add(getPathOrDevNull(outErr.getErrorPath())); cmdLine.addAll(spawn.getArguments()); cmd = new Command( - cmdLine.toArray(new String[]{}), + cmdLine.toArray(new String[0]), spawn.getEnvironment(), execRoot.getPathFile()); } else { @@ -256,7 +256,7 @@ public final class LocalSpawnRunner implements SpawnRunner { spawn.getArguments().toArray(new String[0]), spawn.getEnvironment(), execRoot.getPathFile(), - timeoutSeconds); + policy.getTimeoutMillis()); } long startTime = System.currentTimeMillis(); @@ -277,6 +277,7 @@ public final class LocalSpawnRunner implements SpawnRunner { String msg = e.getMessage() == null ? e.getClass().getName() : e.getMessage(); setState(State.PERMANENT_ERROR); outErr.getErrorStream().write(("Action failed to execute: " + msg + "\n").getBytes(UTF_8)); + outErr.getErrorStream().flush(); return new SpawnResult.Builder() .setStatus(Status.EXECUTION_FAILED) .setExitCode(LOCAL_EXEC_ERROR) @@ -287,8 +288,7 @@ public final class LocalSpawnRunner implements SpawnRunner { long wallTime = System.currentTimeMillis() - startTime; boolean wasTimeout = result.getTerminationStatus().timedout() - || wasTimeout(timeoutSeconds, wallTime) - || result.getTerminationStatus().getRawExitCode() == POSIX_TIMEOUT_EXIT_CODE; + || (useProcessWrapper && wasTimeout(timeoutSeconds, wallTime)); Status status = wasTimeout ? Status.TIMEOUT : Status.SUCCESS; int exitCode = status == Status.TIMEOUT ? POSIX_TIMEOUT_EXIT_CODE |