I didn't know for jdk8 functions destroy and the new one destroyForcibly...

And Jonathan was right in his previous answer, I was looking for a solution in 
Java, I mean a portable one like  in Process class, like the 
"destroyGracefully".
I am looking to signals because it seems to be a simple way to achieve this 
"portable" solution, maybe I'm wrong.

It would be useful (as you said) to have a function to kill "gracefully" 
through Process class, no ?

Nicolas Le Picard

-----Message d'origine-----
De : Alan Bateman [mailto:[email protected]] 
Envoyé : mardi 4 mars 2014 13:12
À : Krystal Mok
Cc : LE PICARD NICOLAS; [email protected]
Objet : Re: How to close a Process and having shutdown hooks called ?

On 04/03/2014 11:51, Krystal Mok wrote:
> Hi Nicolas,
>
> Looks like a well discussed question. On Posix systems, SIGTERM should 
> work for you. That's the default signal sent by the 'kill' command on Linux.
> e.g. please take a look here:
> http://stackoverflow.com/questions/2541597/how-to-gracefully-handle-th
> e-sigkill-signal-in-java
>
> - Kris
>
I think he's on Windows and is looking for destroy to use something other than 
TerminateProcess.

As background, the destroy method was confusingly specified to kill the 
sub-process forcibly but it wasn't implemented this way everywhere. On 
Unix/Linux then the long standing implementation used SIGTERM and so no 
guarantee that it would cause the sub-process to terminate. This mismatch was 
examined in JDK 8 (you'll need to go through the archives of this mailing list 
to see the discussion) and the javadoc updated to make it clear that it is 
implementation specific as to whether it is done forcibly or not. In addition a 
new destroyForcibly was added to do the SIGKILL or TerminateProcess for cases 
where you really want to kill the child. There isn't a corresponding 
destroyGracefully but clearly this would be useful if were feasible to 
implement everywhere.

-Alan.

Reply via email to