Important: This method works differently on different JRE versions.
On JDK 8, this will simply call Process.destroy(). Child processes spawned by the process are not affected.
On JDK 9 and later, this will retrieve the process handle, and destroy the process itself and the children too,
recursively.
The process handle API was introduced in JDK 9. Using it the spawned children can be retrieved from a process,
and iteratively destroyed. The destruction is done by querying if the process supports normal termination, and if
so, destroy()
will be called on them. If they don't support normal termination, or the
destroy()
call returned false
, destroyForcibly()
will be called on them.
This function should be considered as a last resort for destroying a process. Callers are strongly recommended to make sure that the process is exited cleanly by using some interprocess communication methods.
null
if it has not yet terminated.