Connecting Tech Pros Worldwide Forums | Help | Site Map

Transfering control when using system()?

Jenny
Guest
 
Posts: n/a
#1: Jul 23 '05
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.
rking@panoptic.com
Guest
 
Posts: n/a
#2: Jul 23 '05

re: Transfering control when using system()?


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 (rking@panoptic.com)

Rolf Magnus
Guest
 
Posts: n/a
#3: Jul 23 '05

re: Transfering control when using system()?


Jenny wrote:
[color=blue]
> Is this possible with system(), or any other method in C++? My GUI is
> written using the Qt library.[/color]

Why not use QProcess then?

Closed Thread