[Qt-interest] Qt4 & fork()

Miguel Cardenas mfcardenas at gmail.com
Thu Dec 4 03:21:11 CET 2008


Hello list

I need to launch a console application from a program but don't know if
fork() is compatible with Qt...

My idea is to do something like this:

---------------------------------------------------------
#define NULL 0
int pid;

pid = fork();

if ( pid==-1 ) { // parent
   /* error, fork() failed */
} else if ( pid>0 ) { // parent
   /* fork() success */
} else if ( pid==0 ) { // child
   /* fork() success, now launch kde console */
   execlp("konsole",NULL);
}
---------------------------------------------------------

If it is possible then my doubts are:

1) The child process inherits and creates a duplicate Qt application (i.e.
the MainWindow or whole app.)?

2) If not (to first question) would fork() cause unpredictable results to
parent and/or child process?

Thanks for your help


-- 
Miguel Cardenas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20081203/88ab959c/attachment.html 


More information about the Qt-interest-old mailing list