[Qt-interest] Cleanly exit Qt app with <CTRL-C> from Linux console

Jorge Abrines curruscataphractus at gmail.com
Thu Dec 23 13:24:08 CET 2010


Hi Markus,

I think this is not related to signals but to objects being destroyed at main 
exit. Are you creating some kind of blocking objects (sockets, database 
connections)? do you have threads? if so is the message "... x threads didn't 
exit" being printed?

Best regards,

Jorge

Markus Franke wrote:
> 
> Dear all,
> 
> during system development I am running my Qt application from a console.
> 
> If I press <CTRL-C> within the console a SIGINT is sent to the 
> application which is catched by a signal handler. From within this 
> signal handler I am calling QApplication::exit(0) which in turn calls 
> the Destructor of my main QApplication object.
> 
>  From time to time I observe that the application hangs for about 30 
> seconds just at the last line of my main() function which returns the 
> return value of QApplication::exec(). (see code below)
> 
> ---snip---
> int main(int argc, char *argv[])
> {
>     Application* app = new Application(argc, argv);
> 
>     int ret = app->exec();
> 
>     delete app;
> 
>     qDebug("This line is still reached");
>     return ret; // this line is hanging for about 30 seconds
> }
> ---snap---
> 
> Is there anything else which I have to take care off if I want to exit 
> my application via <CTRL-C>?
> 
> 
> Thanks in advance and with best regards,
> Markus
> 
> 
> "Disclaimer: This message is intended only for the use of the individual 
> or entity to
> which it is addressed and may contain information which is privileged, 
> confidential, proprietary,
> or exempt from disclosure under applicable law. If you are not the 
> intended recipient or the person
> responsible for delivering the message to the intended recipient, you 
> are strictly prohibited from
> disclosing, distributing, copying, or in any way using this message. If 
> you have received this
> communication in error, please notify the sender and destroy and delete 
> any copies you may have
> received."
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest



More information about the Qt-interest-old mailing list