diff options
author | gjoranv <gv@yahoo-inc.com> | 2017-03-02 16:11:32 +0100 |
---|---|---|
committer | gjoranv <gv@yahoo-inc.com> | 2017-03-02 16:11:32 +0100 |
commit | 18638a9b8c4b2bafd4aba15d14cf66aff1ee9ce0 (patch) | |
tree | 4ffcff925ffaac0bda213c777da1bbdd1d7f1f84 /vespajlib | |
parent | 165165f56b58e0d8320ccd3d6174754ab22e4794 (diff) |
Return a result even if the exit code isn't in the set of successful values.
Diffstat (limited to 'vespajlib')
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/system/execution/ProcessExecutor.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/system/execution/ProcessExecutor.java b/vespajlib/src/main/java/com/yahoo/system/execution/ProcessExecutor.java index 2837372820b..17d0e4c0caa 100644 --- a/vespajlib/src/main/java/com/yahoo/system/execution/ProcessExecutor.java +++ b/vespajlib/src/main/java/com/yahoo/system/execution/ProcessExecutor.java @@ -3,6 +3,7 @@ package com.yahoo.system.execution; import org.apache.commons.exec.CommandLine; import org.apache.commons.exec.DefaultExecutor; +import org.apache.commons.exec.ExecuteException; import org.apache.commons.exec.ExecuteWatchdog; import org.apache.commons.exec.PumpStreamHandler; @@ -73,7 +74,12 @@ public class ProcessExecutor { executor.setWatchdog(watchDog); executor.setExitValues(successExitCodes); - int exitCode = executor.execute(CommandLine.parse(command)); + int exitCode; + try { + exitCode = executor.execute(CommandLine.parse(command)); + } catch (ExecuteException e) { + exitCode = e.getExitValue(); + } return (watchDog.killedProcess()) ? Optional.empty() : Optional.of(new ProcessResult(exitCode, processOut.toString(), processErr.toString())); } |