JDK-8010217 : (process) Process should provide way to kill process tree
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2013-03-18
  • Updated: 2015-06-04
  • Resolved: 2015-06-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9Fixed
Related Reports
Relates :  
Description
java.lang.Process should provide a way to kill all the sub-processes created by a process when a process created by java.lang.Process is killed.   This typically requires OS-specific native code, and so it is unreasonable to push this off onto the clients of the java.lang.Process API.

The lack of this facility significantly impacts our facilities for testing JDK, since many of our test environments create process and expect to be able to clean them up afterwards in the face of an abnormal exit. This include JCK, jtreg, JPRT and Tonga.
Comments
Provided by 8077350
04-06-2015

See 8077350: JEP 102 Process API Updates Implementation The process tree can be queried and each process destroyed. Process.allChildren().forEach (p -> p.destroy());
04-06-2015

One would like to think that the folk that write shells and similar software would also want to use functionality like this to emulate Unix behavior.
21-03-2013

Yes, the Windows Job Objects have been looked at, we're just not sure how this will work with shell tests that launch their own VMs.
21-03-2013

1. If it can't be done in the platform API, how is client code supposed to do it? 2. Can we add functionality with a spec like "attempts to kill child processes" and @throws UnsupportedOperationException if the operation cannot be attempted on this platform Right now, the platform seems to be taking the opinion that it is better to do nothing on any platform that to do what it can when it can -- and is pushing the buck back on clients like test harnesses and JPRT, with notably substandard results.
19-03-2013

May be something like the notion of process group could help? On unix session id works for this as it sticks to the spawned processes unless they explicitly change it. On windows there's something called "Job". I can give you a bit more details if needed.
19-03-2013

There are several other RFEs for this, it's been look at several times and it just not feasible on all platforms, particularly where there is any notion of parent-child.
19-03-2013