[Qt-interest] Is it safe to fork() after an app.exec()
Will Rutherdale (rutherw)
rutherw at cisco.com
Mon Jun 1 21:53:16 CEST 2009
Correction:
I apologise for an inaccuracy in the Subject. The fork() occurs
*before* the app.exec() but after the QCoreApplication derived object
has been instantiated.
-Will
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com
> [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Will
> Rutherdale (rutherw)
> Sent: 1 June 2009 15:50
> To: qt-interest at trolltech.com
> Subject: [Qt-interest] Is it safe to fork() after an app.exec()
>
> Hi.
>
> In writing a console application using QCoreApplication,
> someone came up
> with the idea of creating a self-starting program that processes
> command-line arguments, then decides whether it wants to
> start itself as
> a server in the background. It is already running a method in
> QCoreApplication, but depending on a certain argument may decide to
> fork. The child process on the other side of the fork() call then
> invokes QCoreApplication::exec(). From that point on you
> have a server
> process listening for commands from dbus.
>
> My question: is this safe to do? Testing so far seems to
> indicate that
> it runs without a hitch. However, without knowing the
> sources in Qt in
> depth, I wonder if the code might ever get confused by the
> fact that the
> pid has changed.
>
> If there is a problem, then I could just start this program out of a
> shell using ampersand notation. (Or possibly fork() first?)
>
> I appreciate any advice on this matter.
>
> -Will
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
More information about the Qt-interest-old
mailing list