diff --git a/src/dorkbox/util/process/ShellAsyncExecutor.java b/src/dorkbox/util/process/ShellAsyncExecutor.java index 5a57fcd..0f43e18 100644 --- a/src/dorkbox/util/process/ShellAsyncExecutor.java +++ b/src/dorkbox/util/process/ShellAsyncExecutor.java @@ -1,10 +1,22 @@ +/* + * Copyright 2017 dorkbox, llc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package dorkbox.util.process; -/** - * - */ public -class ShellAsyncExecutor { +class ShellAsyncExecutor extends ShellExecutor { /** * This is a convenience method to easily create a default process. Will immediately return, and does not wait for the process to finish * @@ -13,12 +25,21 @@ class ShellAsyncExecutor { * * @return true if the process ran successfully (exit value was 0), otherwise false */ - public static void run(String executableName, String... args) { + public static + boolean run(String executableName, String... args) { ShellExecutor shell = new ShellExecutor(); shell.setExecutable(executableName); shell.addArguments(args); shell.createReadWriterThreads(); - shell.start(false); + return shell.start(false) == 0; + } + + @Override + public + int start() { + // always have to make sure separate threads are started, otherwise the calling process can hang. + createReadWriterThreads(); + return super.start(false); } } diff --git a/src/dorkbox/util/process/ShellExecutor.java b/src/dorkbox/util/process/ShellExecutor.java index 17ade54..fe3d58a 100644 --- a/src/dorkbox/util/process/ShellExecutor.java +++ b/src/dorkbox/util/process/ShellExecutor.java @@ -71,7 +71,7 @@ class ShellExecutor { private List fullCommand; /** - * This is a convenience method to easily create a default ShellExecutor. Will block until the process is finished running + * This is a convenience method to easily create a default process. Will block until the process is finished running * * @param executableName the name of the executable to run * @param args the arguments for the executable