Re: [gtk-list] fork()/exec() round 2



The parent process needs to call a wait() function to "reap" the child
process (at least, that's always worked for me).

One of my projects - mconv, not GTK-related one - has the following:

  waitpid (-1, 0, WNOHANG);             /* reap any zombie children */

This gets called by the parent after the child has exited. You could try
writing a simple signal handler in the parent process and having it call
waitpid() as above when it receives SIGCHLD - see signal(2) and signal(7).

By the way the WNOHANG in the example above stops the parent process from
ever actually waiting, so if there are any child processes still running the
parent process doesn't get stuck waiting for them to finish. See the man
page for waitpid, wait(2).

Hope this helps.

- Andrew


On Tue, 25 May 1999, Daniel J. Kressin wrote:

> I've got the following code: (it's short)
[snip]
> This doesn't make sense to me.  Shouldn't the child process *completely*
> disappear when it calls exit(0)?  What's the key morsel of info I'm
> missing here?



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]