child process using execl()
Chris Waters
xtifr@dsp.net
01 Jun 2000 10:00:18 -0700
Alan DuBoff <maestro@SoftOrchestra.com> writes:
> I'm not sure if this is appropriate to ask here, but I'll throw it out
> anyway...
One of the bay area LUG lists would probably have been a better
choice. Or maybe comp.lang.c or comp.unix.programmer or something
like that. (The FAQ for the latter is probably good to have.) I also
recommend a good book on unix or linux programming. David Curry's
_Unix Systems Programming_ (O'Reilly) or Johnson & Troan's _Linux
Application Development_ (Addison Wesley) are among the ones I own.
You might also want to study the source of the many programs you
already have. (One of the reasons it's so nice to have source.)
> I'm forking off a child process (using fork()) and executing an
> application with execl().
See the system(3) and wait(2) man pages. It sounds like you're trying
to reinvent the former, but if not (if you're trying to do something
more complex), then you probably need the latter.
> Specifically, I'm wondering if I have a child process fork'd off and
> it does get killed or terminated, will it return to the calling
> routine on the line after execl()
No. That's system(3) (which doesn't need fork). With exec, to avoid
zombie processes, you have to either call wait(2) to reap the dead
children or trap SIGCHLD (and the latter can be unreliable). Or you
can get really fancy with process groups, but that's non-trivial.