Stop a running process gracefully

For a process started with a Run Configuration is there a way to have it exit gracefully so shutdown hooks are executed? The red square stop button apparently does something equivalent to a SIGKILL so the VM is killed immediately.

The help says there should be another icon (sort of like an archway with an arrow through it) which should do a graceful shutdown of the VM. However, this icon doesn't appear for me. I am using 9.0.3.

My available icons:

Screen shot 2010-10-27 at 11.02.50 AM.PNG

The relevant help section (take note of the Exit option):

Screen shot 2010-10-27 at 11.03.13 AM.PNG

Comment actions Permalink

Hi Michael,
Graceful shutdown is not possible using Java API only. The only way is to call Process.destroy(). The implementation of destroy() method is system-specific. Usually this is "kill without any questions". The "exit" button is implemented using native code. So the reason why it is not present might be either because you are using OSX, or the native library breakgen.dll (  is missing from your library path if you run Win or Linux. The feature may be also explicitly disabled by setting the "" system property to "true".


Comment actions Permalink

I am indeed on a Mac, so that explains why I don't have that button.

However, I discovered yesterday that pressing the red stop button does result in the shutdown hooks being ran (at least on a Mac). For some reason it at first appeared to me that the hooks weren't being executed when using the stop button. Turns out they were.

The workaround is of course to just do a kill -15 on the process IntelliJ spawned which I did a few times until I discovered the hooks were being executed when stopping via IntelliJ.

Thanks for the info.


Please sign in to leave a comment.