PDA

View Full Version : QProcess doesn't terminate



Bagstone
7th February 2008, 14:22
Hello,

I've got a problem with a QProcess.

My MainWindow class calls StartProcessClass. StartProcessClass initalizes a QProcess* member. Then, MainWindow tells the class to start the process (with start(appName), NOT startDetached(appName)).

When I close my MainWindow, I call a slot in StartProcessClass that sends the process a terminate() and closes the MainWindow.

No threads in this context (another subclas of MainWindow has threads, but in no relation to the process class).


Even in the process tree I can clearly see that the appName created process is a child of my program. But when the parent closes, the child doesn't. It's driving me nuts. Any idea?

Bagstone
7th February 2008, 15:10
Apparently this does only happen now when I kill the parent process from the system...

Bagstone
7th February 2008, 16:13
I discovered something even worse:

When I send the process a terminate(), it doesn't ask for saving of unsaved changes.

No one here who can help? :-(

jpn
7th February 2008, 21:04
From QProcess::terminate() docs:


Attempts to terminate the process.

The process may not exit as a result of calling this function (it is given the chance to prompt the user for any unsaved files, etc).

On Windows, terminate() posts a WM_CLOSE message to all toplevel windows of the process and then to the main thread of the process itself. On Unix and Mac OS X the SIGTERM signal is sent.

Console applications on Windows that do not run an event loop, or whose event loop does not handle the WM_CLOSE message, can only be terminated by calling kill().

Bagstone
8th February 2008, 00:43
Yeah, I know that, maybe I didn't state my problems clear enough.

1) Terminate just "kills" the QProcess, it doesn't ask for unsaved changes as it should.

2) If I kill the parent process (via #kill <pid>), the child process continues to run.