By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,194 Members | 847 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,194 IT Pros & Developers. It's quick & easy.

Transfering control when using system()?

P: n/a
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.
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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 (rk***@panoptic.com)

Jul 23 '05 #2

P: n/a
Jenny wrote:
Is this possible with system(), or any other method in C++? My GUI is
written using the Qt library.


Why not use QProcess then?

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.