Re: GChildWatch source -- take two



"Alexis S. L. Carvalho" <alexis cecm usp br> writes:

> The fact that you can only install the signal handler after launching a
> child still feels sort of like using uninitialized data.  I don't see
> where this could be a problem, but then, I'm no Unix guru...

The only problem I came up with was when the user already has a child
handler that calls wait() or waitpid(-1), and the child exits before the
new handler is installed.  I wonder if we should special case
g_child_watch_add (-1|0); and add a return value to GChildWatchFunc so
that the handler can be canceled.

> I don't think this has to be volatile.

It wasn't originally.  I just put it in to make Alex feel better. (-;

> > +static void
> > +g_child_watch_signal_handler (int signum)
> > +{
> > +  child_watch_count ++;
> > +  /* guard against us modifying errno during the write */
> > +  int old_errno = errno;
> 
> The declaration should be in the beginning of the block.

Right.  Moved on my copy.

> Now the bad news:  I'm afraid I wasn't able to run your child-test
> correctly.  I don't really know the internals of GMainLoop, but if I
> understood correctly, it was always the thread running in main that
> called waitpid.  It always failed with ECHILD (No child processes).

I may have sent a bogus copy of child-test.c in retrospect.  Let me
attach another copy instead.

Thanks,
-Jonathan

Attachment: child-test.c
Description: new child test file.



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