diff options
author | 2015-08-31 16:30:17 +0000 | |
---|---|---|
committer | 2015-08-31 19:21:41 +0000 | |
commit | c7c25d9bc86cc5565b4f5a32a08a0ff22a6aa95d (patch) | |
tree | 84b83e2ed412c5c8d7bf028b278eb6fd94a8e287 /src/main/java/com/google | |
parent | 0f7ba34748579faea70e42dfdf60a9625a88f425 (diff) |
Send the output of spawns ran in worker processes to the outErr of the execution context instead of printing it to System.err.
--
MOS_MIGRATED_REVID=101941516
Diffstat (limited to 'src/main/java/com/google')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnStrategy.java | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnStrategy.java b/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnStrategy.java index d696fc988f..8fb7ef29a6 100644 --- a/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnStrategy.java +++ b/src/main/java/com/google/devtools/build/lib/worker/WorkerSpawnStrategy.java @@ -27,6 +27,7 @@ import com.google.devtools.build.lib.actions.Spawn; import com.google.devtools.build.lib.actions.SpawnActionContext; import com.google.devtools.build.lib.actions.UserExecException; import com.google.devtools.build.lib.concurrent.ThreadSafety; +import com.google.devtools.build.lib.util.io.FileOutErr; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.worker.WorkerProtocol.WorkRequest; import com.google.devtools.build.lib.worker.WorkerProtocol.WorkResponse; @@ -78,6 +79,8 @@ final class WorkerSpawnStrategy implements SpawnActionContext { false, "Must have parameter file as last arg, got args: " + spawn.getArguments()); } + FileOutErr outErr = actionExecutionContext.getFileOutErr(); + ImmutableList<String> args = ImmutableList.<String>builder() .addAll(spawn.getArguments().subList(0, spawn.getArguments().size() - 1)) .add("--persistent_worker") @@ -98,17 +101,19 @@ final class WorkerSpawnStrategy implements SpawnActionContext { WorkResponse response = WorkResponse.parseDelimitedFrom(worker.getInputStream()); if (response == null) { - throw new UserExecException("Worker did not return a correct WorkResponse"); + throw new UserExecException( + "Worker process did not return a correct WorkResponse. This is probably caused by a " + + "bug in the worker, writing unexpected other data to stdout."); } String trimmedOutput = response.getOutput().trim(); if (!trimmedOutput.isEmpty()) { - System.err.println(trimmedOutput); + outErr.getErrorStream().write(trimmedOutput.getBytes()); } if (response.getExitCode() != 0) { - throw new UserExecException(String.format("Failed with exit code: %d.", - response.getExitCode())); + throw new UserExecException( + String.format("Worker process failed with exit code: %d.", response.getExitCode())); } } finally { if (worker != null) { |