How to stop running process in debug mode?

In run mode i there is a button "Exit"
and in debug mode there is no such button

25 comments
Comment actions Permalink

+1
It's 2017 but the problem is still actual (checked on 2016.3.1 under Windows).
It has become especially important with Spring Boot applications where gracefull exit covers significant part of program lifecycle logic.

3
Comment actions Permalink

Dear all, please excuse me for aggressiveness, but it's only because you mocking me

Would you explain what difference it makes in terms of how the "stopped" program behaves ?

the Exit command send Exit signal to the program
and Stop command crashes jvm

in case of console program Exit is like "ctrl+c"
in case of windowed program Exit is like "alt+f4" or like clicking small cross at the right top of the window
(in linux its like kill or kill -TERM)

in both cases Stop is like open task manager, choose process and click "End process" button
(in linux it like kill -9 or kill -KILL)

in case of Exit program can shutdown right way, e.g. it can save some data in file, or can send email that it was stopped
in case of Stop jvm is aborted, program can't do anything

1
Comment actions Permalink

Long-running customer and fan of IntelliJ. We are currently in the process of getting some great Docker Postgres plugin working for Spring Boot Auto Configured applications, enabling us to work with just one database in all run-configurations.

However, to run this functionality in IntelliJ, it requires a Spring @PreDestroy to be triggered. Not only in Run-mode (which has the exit button), but also in Debug-mode (which does not have the exit button). As you are aware, the stop button just kills the JVM and @PreDestroy calls are ignored.

Wi Wi's suggestion is great. If you guys can implement a proper exit button for debug mode, beers here will be popped to your hail your benevolence. 

1
Comment actions Permalink

there's a "STOP" button which terminates the JVM is that what you seek ?

0
Comment actions Permalink

no
that button destroys jvm
it doesn't stop process

in run mode there are both buttons but unfortunately in debug mode there is only one

0
Comment actions Permalink

Between the resume (green triangle) and the stop (red square) there's a blue pause button, using the conventional consumer electronics pause iconography, two parallel vertical bars. This will do what (I think) you want.


Randall Schulz

0
Comment actions Permalink

Hello botWi,

In run mode i there is a button "Exit"
and in debug mode there is no such button


Fourth button from the top ("Stop").

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

are you kidding me?

pause button do PAUSE of the program
stop button do ABORT of the program, it crashes jvm, it doesn't exit program, it's like kill program from task manager
exit button do EXIT, like when you close any program by alt+f4

i need exit button in debug mode
now to exit i use other external programs, this is very unconvenient

0
Comment actions Permalink

Dmitry, why are you mocking me?

you really don't understand the difference between Stop and Exit?
even if you don't understand, don't you think it's strange that in run mode there are 2 buttons Stop/Exit and in debug mode only 1 button Stop?
maybe you'll remove Exit button from run mode too?
it will be great joke!

0
Comment actions Permalink

Would you explain what difference it makes in terms of how the "stopped" program behaves ?

It may be just me but you seem overly agressive

0
Comment actions Permalink

thanks for explaining :)

0
Comment actions Permalink

Hello botWi,

In Run mode, we launch your application through a special wrapper class which
communicates with the parent instance of IntelliJ IDEA and can receive "shutdown"
or "dump threads" commands. In Debug mode, no such wrapper class is used.
You can effectively exit the application by evaluating "System.exit(0)" using
the Alt-F8 (Evaluate Expression) dialog, and we'll probably add the button
to do this for you automatically.

Dmitry, why are you mocking me?

you really don't understand the difference between Stop and Exit?

even if you don't understand, don't you think it's strange that in run
mode there are 2 buttons Stop/Exit and in debug mode only 1 button
Stop?

maybe you'll remove Exit button from run mode too?

it will be great joke!

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Thanks a lot
System.exit(0) - very good idea :)

the only trouble is that program should be paused at some breakpoint
it's strange, but i can't just click "Pause" and then evaluate system.exit(0)

0
Comment actions Permalink

+1

Effectively makes debugging shutdown-logic impossible

0
Comment actions Permalink

+1

This would be a neat and very wanted feature!

0
Comment actions Permalink

Is there any any youtrack issue for this?

0
Comment actions Permalink

OK... But the first issue is Fixed without there being a fix implemented? 

My typical use-case is that I have lots of JavaExec tasks defined in Gradle and these run fine, but when exiting these from debug mode, it just terminates the debug session and then there is a 10s delay before the gradle daemon kills the debugged application.

Is there an issue that covers this?

0
Comment actions Permalink

In case of Gradle IDEA uses gradle tooling API's cancellation mechanism, so we just ask gradle to stop the task execution, but we can not manage the target process lifecycle.

0
Comment actions Permalink

Yes, this feature should help.

0
Comment actions Permalink

https://github.com/gradle/gradle/issues/1128 was resolved two months ago. Any updates on the issue?

0
Comment actions Permalink

I just tried to debug a spring-boot application. It did not stop at my breakpoint, and when I stopped the app using the stop button in the debug window, the application keeps running (I can still hit it in my browser). I tried spring-boot:stop, but the application keeps running. I closed IntelliJ completely, but the application keeps running! I have no idea how to stop it, other than to reboot my pc.

0
Comment actions Permalink

Kills the process? It looks like Spring/application specific issue not related to the IDE.

0

Please sign in to leave a comment.