Code polish for the shell executors
This commit is contained in:
parent
ec0772a9b0
commit
2c31963337
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ class ShellExecutor {
|
||||
private List<String> 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
|
||||
|
Loading…
Reference in New Issue
Block a user