PDA

View Full Version : Qt Creator Force Stop



Azraiyl
15th November 2010, 17:42
If an application is started through Qt Creator 2 (no Debugging) a small red rectangle is enabled to stop the application. After a while Qt Creator ask for "Force Stop" because the application is not responding (happens with a simple Qt Console application). But even if I handle all possible Linux signals, I'm unable to gracefully quit the application. Does anyone now what happens behinde the scenes when the button is pressed (I was unable to see anything usefull through strace)?

wysota
15th November 2010, 18:12
Most likely Creator launches your program via QProcess so when you ask it to stop the program it either does QProcess::terminate() or QProcess::kill() (which of the two it is, you can check in the source code). If Creator asks to force stop, then most likely it tries with terminate() first and if it fails, it does kill().

Azraiyl
15th November 2010, 18:34
I handle SIGTERM and it seams that there is no sign, that this signal is sent to the process. I already looked and the source. It seems that there is RunControl class which only has the methods start/stop. I've to crawl a bit more deeply I guess.

wysota
15th November 2010, 18:35
Does the handler get activated if you run your program from the command line?

Azraiyl
16th November 2010, 12:27
Yes. kill <pid> works as expected. The signal handler only sets a boolean, the main loop quits when the boolean is set.

When I analyzed the code correctly it looks like SIGTERM is not sent from Qt Creator when the Stop Button is pressed. Only a condition is checked if the process is still running. After the "Force Quit" button is pressed a SIGTERM is sent, and then a SIGKILL (through QProcess terminate and kill), but this is IMO too late (there is no reason the developer has to press the button always twice). If I'm not completly wrong here I think it's an inconvenient behaviour from Qt Creator.

wysota
16th November 2010, 13:22
My Creator simply asks me if I want to stop the program. I had situations when I pressed the stop switch by accident so I'm not that annoyed that a dialog pops up asking me whether I want to terminate the app. I'm sure disabling the dialog should be easy - just comment the appropriate line and rebuild the plugin responsible for handling the situation.