1

I have created two programs A and B. B is designed to be as a 32-bits QProcess started within a 64-bits A. These programs communicate nicely via stdin, stdout and QSharedMemory.

A:A() {
 QProcess *p = new QProcess(this);  
 p->start("B.exe");
}
A:~A() {
 p->deleteLater();
}

Now, if A is closed B will also be shut down. However, if I in Windows Task Manager ends the process A, B will keep living on the loose, and the cpu usage of B will be through the roof. Why?

How can I shut down B if A is immediately destroyed?

Magnus
  • 13
  • 3

1 Answers1

1

Try to close() (or kill()) the other process from your DTOR and do a raw delete p afterwards. I had a similar issue when using a QextSerialPort object which, too, tended to stay around as a ghost when deleted with deleteLater(), however promptly packed up and left when immediately deleted.

Manjabes
  • 1,714
  • 3
  • 19
  • 32
  • I did some debugging and found that when application was closed via Windows Task Manager or "red square button" in QtCreator, the DTOR of A was never reached. That's why the process lives on, and why 'close()' or 'kill()' does not work either... – Magnus May 31 '11 at 14:21