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

execute a new programm without beeing blocked

P: n/a
Hi all,
I want to execute a new program in a c++ program without
beeing blocked. After the child process is created both
processes should run idependend.

My method at the moment:

execute( QString cmd )
{
int pid = -1;
pid = fork();
if(pid == 0)
{
execlp(cmd, NULL);
}
....
}

This works fine until I close the child process.
Then i get many errorreports in the console and the parent program hangs up.

errorexamples on my SuSe 9.1 Linux:
X Error: RenderBadPicture (invalid Picture parameter) 180
Major opcode: 153
Minor opcode: 5
Resource id: 0x3a00167
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
Major opcode: 62
Minor opcode: 0
Resource id: 0x3a00166
Xlib: unexpected async reply (sequence 0x60cc)!
I tried to use the system(cmd) - command in the child process with
the same outcome.

Q: Why does quitting the child program effect my first program ?
Is there a method similar to system() which dosen't block the parent
process?

ps: can fork() be used under windows as well or do i have to use
createporcess()?

Thank for your time.

Jul 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Thomas wrote:
I want to execute a new program in a c++ program without
beeing blocked. After the child process is created both
processes should run idependend.

My method at the moment:

execute( QString cmd )
{
int pid = -1;
pid = fork();
if(pid == 0)
{
execlp(cmd, NULL);
}
...
}

This works fine until I close the child process.
Then i get many errorreports in the console and the parent program hangs up.

errorexamples on my SuSe 9.1 Linux:
X Error: RenderBadPicture (invalid Picture parameter) 180
Major opcode: 153
Minor opcode: 5
Resource id: 0x3a00167
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
Major opcode: 62
Minor opcode: 0
Resource id: 0x3a00166
Xlib: unexpected async reply (sequence 0x60cc)!
I tried to use the system(cmd) - command in the child process with
the same outcome.

Q: Why does quitting the child program effect my first program ?
There is no answer to this question in C++ terms. 'fork' is not
a standard C++ function.
Is there a method similar to system() which dosen't block the parent
process?
Not in the Standard C++.

ps: can fork() be used under windows as well or do i have to use
createporcess()?


You should ask this in a Windows newsgroup.

In general, interprocess communication and multiprocessing is not
supported by the language. It is a feature of the OS and as such needs
to be discussed in a newsgroup dedicated to theat OS...

Oh, I didn't follow your follow-ups. Since I read this in comp.lang.c++,
I reply in comp.lang.c++. If you need to discuss this elsewhere, post
there to begin with (which I strongly recommend).

V
Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.