Re: GChildWatch source -- take two

Thus spake Jonathan Blandford:
> "Alexis S. L. Carvalho" <alexis cecm usp br> writes:
> > Same problem: the thread that calls waitpid is the one that runs in the
> > function main, and because of bugs in LinuxThreads it can't wait for the
> > children of the other threads.
> Looking again, that analysis doesn't make sense.  We run the following
> code in a thread:
>   ...
>   new_main_loop = g_main_loop_new (NULL, FALSE);

I don't know the internals of GMainLoop, but I think that if you pass
NULL as the first argument in this call, new_main_loop will share the
(default) GMainContext with the thread running in main.  For some
reason, it's the thread running in main that is woken up to handle the
events of this context.

If I put something like

  GMainContext *context;
  context = g_main_context_new ();
  new_main_loop = g_main_loop_new (context, FALSE);

in its place, everything works.

> That means that the thread should be alive when the child exits, and the
> waitpid should be run from within that thread by the new_main_loop
> within that thread.

The "thread exits before child" was just an example of a particularly
nasty situation that is possible with LinuxThreads.


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