]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/tasks/SystemCall.java
Attachments management
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.simple / src / main / java / org / argeo / slc / core / execution / tasks / SystemCall.java
index 38b0f78b4f5b759390a3d1141145c28e00a371a2..574e21d9e3ba195759bda74748f2a713afbae308 100644 (file)
@@ -16,9 +16,8 @@ import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.slc.SlcException;
-import org.argeo.slc.execution.Executable;
 
-public class SystemCall implements Executable {
+public class SystemCall implements Runnable {
        // TODO: specify environment variables
 
        private final Log log = LogFactory.getLog(getClass());
@@ -37,7 +36,7 @@ public class SystemCall implements Executable {
        private Map<String, List<String>> osCommands = new HashMap<String, List<String>>();
        private Map<String, String> osCmds = new HashMap<String, String>();
 
-       public void execute() {
+       public void run() {
                try {
                        if (log.isTraceEnabled()) {
                                log.debug("os.name=" + System.getProperty("os.name"));
@@ -99,7 +98,7 @@ public class SystemCall implements Executable {
                        };
                        stdOutThread.start();
                        StreamReaderThread stdErrThread = new StreamReaderThread(process
-                                       .getInputStream()) {
+                                       .getErrorStream()) {
                                protected void callback(String line) {
                                        stdErrCallback(line);
                                }
@@ -111,8 +110,10 @@ public class SystemCall implements Executable {
                        // Wait for the end of the process
                        if (synchronous) {
                                Integer exitCode = process.waitFor();
-                               if (exitCode != 0)
+                               if (exitCode != 0) {
+                                       Thread.sleep(5000);// leave the process a chance to log
                                        log.warn("Process return exit code " + exitCode);
+                               }
                        } else {
                                // asynchronous: return
                        }
@@ -132,7 +133,7 @@ public class SystemCall implements Executable {
                else
                        return dir.getPath();
        }
-       
+
        protected void stdOutCallback(String line) {
                log(stdOutLogLevel, line);
        }