http://www.faqs.org/faqs/unix-faq/programmer/faq/
<See: "Daemon utility functions" for a C version of what Mark posted>
<See also: spawn_background_command() in "Job Control example" for code
for spawning background jobs in C. In it's header it says: "like
system(), but executes the specified command as a background job">
<See also "1.7 How do I get my program to act like a daemon?">
http://www.faqs.org/faqs/unix-faq/faq/part3/
3.13) How do I get rid of zombie processes that persevere?
<...much flavor-specific stuff deleted...>
One more thing -- if you don't want to go through all of this
trouble, there is a portable way to avoid this problem, although it
is somewhat less efficient. Your parent process should fork, and
then wait right there ... for the child process to terminate. The
child process then forks again, giving you a child and a grandchild.
The child exits immediately (and hence the parent waiting for it
notices its death and continues to work), and the grandchild does
whatever the child was originally supposed to. Since its parent
died, it is inherited by init, which will do whatever waiting is
needed. This method is inefficient because it requires an extra
fork, but is pretty much completely portable.
Randy
--
Randall Hopper (mailto:[EMAIL PROTECTED])
Lockheed Martin Operation Support
EPA Scientific Visualization Center
US EPA N127-01; RTP, NC 27711