From e38a2e1ee662db2c795683ddd32c300bc6ccae02 Mon Sep 17 00:00:00 2001 From: Laurent Clouet Date: Tue, 2 Dec 2014 20:23:04 +0000 Subject: [PATCH] Bugfix: do not close the handle because destructing the object does not mean that the process is dead --- src/com/sheepit/client/os/windows/WinProcess.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/sheepit/client/os/windows/WinProcess.java b/src/com/sheepit/client/os/windows/WinProcess.java index 6cdc113..2cbe9f5 100644 --- a/src/com/sheepit/client/os/windows/WinProcess.java +++ b/src/com/sheepit/client/os/windows/WinProcess.java @@ -96,7 +96,7 @@ public class WinProcess { @Override protected void finalize() throws Throwable { if (this.handle != null) { - Kernel32.INSTANCE.CloseHandle(this.handle); + // Kernel32.INSTANCE.CloseHandle(this.handle); // do not close the handle because the parent Process object might still alive this.handle = null; } this.pid = -1; @@ -123,6 +123,7 @@ public class WinProcess { private void terminate() { Kernel32.INSTANCE.TerminateProcess(this.handle, 0); + Kernel32.INSTANCE.CloseHandle(this.handle); // we are sure that the parent Process object is dead } private List getChildren() throws IOException {