How to check if child is done executing ...

L

Lebplaya

Ok ... heres my situation.

I need to run 4 child processes in parallel. each child process will
exececute a different program. How would i go about sending the PID of
the child back to the parent upon execution of each program. I need
the parent to print out a message upon successful completion of the
exec statements. Since the children have to run in parallel, i cannot
run the first child and wait for completion ... they must all be run
at the same relative time. Any help here would be greatly appreciated.

Thanks
 
J

Jack Klein

Ok ... heres my situation.

I need to run 4 child processes in parallel. each child process will

[snip]

Then you're asking in the wrong place. The C language does not have
processes or PIDs. These are non-standard extensions provided by your
particular compiler/operating system combination. You need to ask in
a group that supports that combination, it is not a C language issue.

Since you posted via Google, your headers don't reveal your platform,
but most likely you want either or
 
A

Alex Pankratov

fork() them all first remembering their PIDs, then call
wait() 4 times and check its return value to see which
child has completed the execution.
 

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
474,138
Messages
2,570,804
Members
47,349
Latest member
jojonoy597

Latest Threads

Top