[Interest] Process started with QProcess::startDetached is still a child, and is killed when parent quits

Wiebe Cazemier wiebe at halfgaar.net
Thu Mar 6 09:03:07 CET 2014


----- Original Message -----
> From: "alexander golks" <alex at golks.de>
> To: interest at qt-project.org
> Sent: Thursday, 6 March, 2014 8:49:08 AM
> Subject: Re: [Interest] Process started with QProcess::startDetached is still a child, and is killed when parent
> quits
> 
> Am Wed, 5 Mar 2014 21:40:11 +0100 (CET)
> schrieb Wiebe Cazemier <wiebe at halfgaar.net>:
> 
> > So, how do I really start a detached process? Is there a similar way to how
> > Linux parents orphaned processes to init?
> 
> i have a process to restart a service at a given time, and i do it this way:
> 
>   QProcess* batchProcess=new QProcess();
>   batchProcess->start(batchFilename);
> 
> QProcess destructor kills the procress, perhaps thats your issue, too. so
> when using a "dangling" pointer process, the process itself lives on.
> 
> i must confess, i don't know, how windows handles this, but it works ;)
> 
> alex

It's not the destructor that kills the process in my case. One reason being that openUrl and startDetached are static methods. 

And, in the debugger, after the method is done, it steps back over all the stack variables, calling the destructors, and I can step all the way of the program and only at the very end does the started process die (longer after anything in the method has gone out of scope).



More information about the Interest mailing list