execute a new programm without beeing blocked

T

Thomas

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.
 
V

Victor Bazarov

Thomas said:
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
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top