Skip to content

Commit 9984092

Browse files
committed
[SYSTEMDS-3903] Fix federated tests worker process shutdown windows
A recent commit added the graceful termination w/ kill -SIGINT before waiting and then forcefully destroying the process. Due to the POSIX- specific command these tests now locally failed on windows. This patch fixes it by attempting a taskkill on windows (which without /F usually fails to terminate though) and then uses the standard termination.
1 parent 480e9a0 commit 9984092

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/test/java/org/apache/sysds/test/TestUtils.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3493,21 +3493,23 @@ public static void shutdownThread(Process t) {
34933493
if( t != null ) {
34943494
sendSigInt(t);// Attempt graceful termination
34953495
try {
3496-
// Wait up to 1 second for the process to exit
3497-
if (!t.waitFor(10, TimeUnit.SECONDS)) {
3498-
// If still alive after 1 second, force kill
3499-
Process forciblyDestroyed = t.destroyForcibly();
3500-
forciblyDestroyed.waitFor(); // Wait until it's definitely terminated
3501-
}
3502-
} catch (InterruptedException e) {
3503-
e.printStackTrace();
3504-
}
3496+
// Wait up to 1 second for the process to exit
3497+
if (!t.waitFor(10, TimeUnit.SECONDS)) {
3498+
// If still alive after 1 second, force kill
3499+
Process forciblyDestroyed = t.destroyForcibly();
3500+
forciblyDestroyed.waitFor(); // Wait until it's definitely terminated
3501+
}
3502+
} catch (InterruptedException e) {
3503+
e.printStackTrace();
3504+
}
35053505
}
35063506
}
35073507

35083508
public static void sendSigInt(Process process) {
35093509
long pid = process.pid();
3510-
ProcessBuilder pb = new ProcessBuilder("kill", "-SIGINT", Long.toString(pid));
3510+
ProcessBuilder pb = System.getProperty("os.name").startsWith("Win") ?
3511+
new ProcessBuilder("taskkill", "/pid", Long.toString(pid)) : // add "/F" to force
3512+
new ProcessBuilder("kill", "-SIGINT", Long.toString(pid));
35113513
try {
35123514
pb.inheritIO().start().waitFor();
35133515
}

0 commit comments

Comments
 (0)