diff options
author | Hannes Wellmann | 2020-09-25 11:46:09 +0000 |
---|---|---|
committer | Andrey Loskutov | 2020-10-27 21:31:52 +0000 |
commit | 355226e13346a6516ee74541e993be37ad7622ba (patch) | |
tree | 92d49a782991f0af2d1002c30b9a415f55f7df5a /org.eclipse.debug.core | |
parent | 67a74d76e7a99b3252d4ca29167f33e55cee9740 (diff) | |
download | eclipse.platform.debug-355226e13346a6516ee74541e993be37ad7622ba.tar.gz eclipse.platform.debug-355226e13346a6516ee74541e993be37ad7622ba.tar.xz eclipse.platform.debug-355226e13346a6516ee74541e993be37ad7622ba.zip |
Bug 567345 - Terminate descendants of RuntimeProcessY20201030-1200Y20201029-1200Y20201028-1200I20201029-1800I20201028-1800I20201028-0800I20201028-0610I20201028-0130I20201028-0020I20201027-2350I20201027-1800
The descendants (sub-processes and their recursive sub-processes) of the
java.lang.Process wrapped by a RuntimeProcess are destroyed too.
Change-Id: Ibabe73e34543aa1ff0be7361e63c1bab52a4f538
Signed-off-by: Hannes Wellmann <wellmann.hannes1@gmx.net>
Diffstat (limited to 'org.eclipse.debug.core')
-rw-r--r-- | org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java index 6cf829bca..51186f956 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/RuntimeProcess.java @@ -13,14 +13,16 @@ *******************************************************************************/ package org.eclipse.debug.core.model; - import java.nio.charset.Charset; import java.nio.charset.IllegalCharsetNameException; import java.nio.charset.UnsupportedCharsetException; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.PlatformObject; @@ -34,7 +36,6 @@ import org.eclipse.debug.internal.core.DebugCoreMessages; import org.eclipse.debug.internal.core.NullStreamsProxy; import org.eclipse.debug.internal.core.StreamsProxy; - /** * Standard implementation of an <code>IProcess</code> that wrappers a system * process (<code>java.lang.Process</code>). @@ -203,11 +204,21 @@ public class RuntimeProcess extends PlatformObject implements IProcess { public void terminate() throws DebugException { if (!isTerminated()) { if (fStreamsProxy instanceof StreamsProxy) { - ((StreamsProxy)fStreamsProxy).kill(); + ((StreamsProxy) fStreamsProxy).kill(); } Process process = getSystemProcess(); if (process != null) { + + List<ProcessHandle> descendants; // only a snapshot! + try { + descendants = process.descendants().collect(Collectors.toList()); + } catch (UnsupportedOperationException e) { + // JVM may not support toHandle() -> assume no descendants + descendants = Collections.emptyList(); + } + process.destroy(); + descendants.forEach(ProcessHandle::destroy); } int attempts = 0; while (attempts < MAX_WAIT_FOR_DEATH_ATTEMPTS) { |