Transfering control when using system()?

J

Jenny

Hi,

I'm writing a GUI interface for a program that executes from the
command line in Unix. I've used system("command..") to do it, and it
all works fine. However, the problem is that the ideal behaviour would
be for the GUI to disappear once the program starts to run. I know
that all system() does is call up the command procesor and execute the
command before passing control back to the origin program (in my case
the GUI), but I need the GUI to pass control completely to the program
and just exit so that closing the GUI won't close the program as well.
Is this possible with system(), or any other method in C++? My GUI is
written using the Qt library.

Thanks for any help!

Jenny.
 
R

rking

What about something like this?:

int main() {
// ...qt code goes here
if (fork() == 0) {
// close/clean up GUI
} else {
system(whateverCmd);
}
return 0;
}

My main concern would be that the GUI would get cleaned up twice.
Surely the Qt designers have had other users attempt this, so surely
there's a sane way to handle it.

Hope this helps!
-Ryan King ([email protected])
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top