In Linux/Qt I have a GUI application. The GUI starts up additional child processes using QProcess. To close the child processes I use QProcess::close().
Does QProcess::close() raise the unix SIGTERM signal for the child process?
(I have linked to the Qt documentation for QProcess and close() because I can not tell from the documentation if a unix signal is raised…)
UPDATE: changed question to ask about a specific unix signal: SIGTERM.
Today I found out that QProcess::close() does not raise the SIGTERM signal. To debug this issue I am capturing the stderr and stdout of the child process. Spoiler: QProcess::terminate() does raise the SIGTERM signal.
Child process code to handle unix SIGTERM signal:
Parent process code that handles close() or terminate() of the child:
When the parent uses
QProcess::terminate(), the child process output is:When the parent uses `QProcess::close(), the child process output is:
The output from the
terminate()experiment proves that the child process is getting a SIGTERM signal.The output from the
close()experiment proves that the child process is not getting the SIGTERM signal.Conclusion:
If you want to send the child process the SIGTERM signal, use QProcess::terminate().