Skip to content

Commit eec483a

Browse files
Refactor : Update ShutdownCommand.java
1 parent f993d7c commit eec483a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/main/java/com/mycmd/commands/ShutdownCommand.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,16 @@ public void execute(String[] args, ShellContext context) throws IOException {
9595

9696
outputThread.start();
9797
errorThread.start();
98-
outputThread.join();
99-
errorThread.join();
100-
101-
if (!process.waitFor(30, TimeUnit.SECONDS)) {
98+
99+
boolean finished = process.waitFor(30, TimeUnit.SECONDS);
100+
if (!finished) {
102101
process.destroyForcibly();
103102
System.out.println("Command timed out.");
103+
process.waitFor();
104104
}
105+
106+
outputThread.join();
107+
errorThread.join();
105108

106109
} catch (Exception e) {
107110
System.out.println("Error executing shutdown: " + e.getMessage());

0 commit comments

Comments
 (0)