JDK-4485742 : Process.destroy() and shutdown hook platform specific behavior
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.3.1
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: solaris_8
  • CPU: sparc
  • Submitted: 2001-07-29
  • Updated: 2014-09-05
  • Resolved: 2001-08-15
Related Reports
Relates :  

Name: boT120536			Date: 07/29/2001

[also see bug # 4412451]
java version "1.3.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-b24)
Java HotSpot(TM) Client VM (build 1.3.1-b24, mixed mode)


1) MyClass1 sets in its constructor a shutdown hook and the main method of
MyClass1 calls this constructor.
2) A MyClass2 main method creates a new process using Runtime.exec() method
with as the command line a java command with as the main class MyClass1.
The retured object by the Runtime.exec() method is the Process object on the
MyClass1 runtime.
3) We call Process.destroy() method on the MyClass1 Process object.

Here 2 different behaviors are obesrved:
1) On Solaris the shutdown hook is triggered
2) Whereas on NT it is not.

Problem: The behavior of the Process.destroy() method differs on NT and Solaris
(Review ID: 127844) 

EVALUATION Not a bug. Using Process.destroy() is the last resort, and there is no garantee that shutdown hooks will be run in the case when the process is another VM instance. In particular, on Windows, we use TerminateProcess() call, which terminates the process abruptly. We could use softer ExitProcess() call, which would allow to run shutdown hooks, but ExitProcess could block on stubborn processes. Since Process.destroy() is the last resort, using TerminateProcess() in it is justified. No garantees can be made with respect to a programming technique, which relies on using shutdown hooks and Process.destroy(). ###@###.### 2001-08-15