child process using execl()

Chris Waters xtifr@dsp.net
01 Jun 2000 11:44:56 -0700


Alan DuBoff <maestro@SoftOrchestra.com> writes:
> Chris Waters wrote:
> > > One of the bay area LUG lists would probably have been a better
> > choice.

> Yeah, I used to use SVLUG, but there is so much garbage on the list
> from people ranting about how cool they think they look in the
> mirror, it's enough to make you regurgitate...:-/

That's why I use killfiles.  ;-)

Anyway, the _Linux Application Development_ book definitely covers the
questions you're asking.  The example program they develop in that
book is a small shell, which does lots of forking and execing.

> I know there is a waitpid() call, are you saying to wait for the
> children to die by using something similar?

If you want to wait for a child to finish, then yes, use wait or
waitpid.  If you only have one child at a time, then wait is probably
easier (I think it's also a little more standard/portable).

> I'm trying to avoid system(), I had some of those in that were
> giving me problems. I'm using the msgctl, msgsnd, msgrcv functions
> for IPC between the parent and child, that seems to work ok...

Ah, now if parent and child are in active communication, then maybe
you don't want to call wait until a) the child informs you that it's
planning to die, or b) you suspect that the child has died for other
reasons.  It's often a good idea to kill the child and then call
wait.  (The parent knows the child's pid.)

And yes, if parent and child need to communicate, system() is not what
you want.  But you might find it interesting to see how it's defined.

HTH, cheers
-- 
Chris Waters   xtifr@dsp.net | I have a truly elegant proof of the
      or    xtifr@debian.org | above, but it is too long to fit into
http://www.dsp.net/xtifr     | this .signature file.