I am working on linux and I realized that my application was leaving behind daemon processes when I close it with the “Stop” button on Qt creator IDE. I want to handle these cases so the application close the same way as when I close the main window. To write the handlers, I need to know which signals it corresponds to.
Share
Digging into QtCreator’s code, I can see that QtCreator uses a QProcess internally to launch your app. The red “stop” button is connected to
ApplicationLauncher::stop(), which terminates your process in one of two ways depending if it’s a GUI app or a console app, but in both cases, the result end up to be the same on Linux.For a GUI app,
ApplicationLaunchercallsQProcess::terminate(), which in turn sends a SIGTERM (on Linux) signal to your daemon. It then waits (withwaitForFinished()) for 1 second, and if the daemon hasn’t quit by then, it callsQProcess::kill(), sendingSIGKILL.For a console app,
ApplicationLauncherdelegates the termination to theConsoleProcessutility class. On Linux,ConsoleProcess::stop()will act similar toApplicationLauncherfor a GUI app, which is first sendingSIGTERM, then waiting for 1 second, and sendingSIGKILLif it hasn’t terminated yet.You will find the relevant code from QtCreator here: