Skip to content

Commit b080215

Browse files
committed
utils: honor custom timeout for script execution for exit value
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent d99cf93 commit b080215

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

utils/src/main/java/com/cloud/utils/script/Script.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,8 @@ public static String getExecutableAbsolutePath(String executable) {
660660
return executable;
661661
}
662662

663-
private static Script getScriptForCommandRun(String... command) {
664-
Script s = new Script(command[0], 0);
663+
private static Script getScriptForCommandRun(long timeout, String... command) {
664+
Script s = new Script(command[0], timeout);
665665
if (command.length > 1) {
666666
for (int i = 1; i < command.length; ++i) {
667667
s.add(command[i]);
@@ -670,12 +670,16 @@ private static Script getScriptForCommandRun(String... command) {
670670
return s;
671671
}
672672

673+
private static Script getScriptForCommandRun(String... command) {
674+
return getScriptForCommandRun(0, command);
675+
}
676+
673677
public static String executeCommand(String... command) {
674678
return runScript(getScriptForCommandRun(command));
675679
}
676680

677681
public static int executeCommandForExitValue(long timeout, String... command) {
678-
return runScriptForExitValue(getScriptForCommandRun(command));
682+
return runScriptForExitValue(getScriptForCommandRun(timeout, command));
679683
}
680684

681685
public static int executeCommandForExitValue(String... command) {

0 commit comments

Comments
 (0)