[Qt-interest] Is it safe to fork() after an app.exec()
Will Rutherdale (rutherw)
rutherw at cisco.com
Mon Jun 1 21:49:57 CEST 2009
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
More information about the Qt-interest-old
mailing list