RE: Re: gthread and fork/exec



Hi Lin,

> >To your program: It runs here without problems. But there are some
> >problems, which make running fork in GLib multithreaded programs
> >unreliable. Just now there is no g_thread_atfork command like in
> >pthread. It would be needed to really make it work. See the
> >pthread_atfork manpage, why this is needed.
> >
> >I don't think, we ever want to have anything like that in GLib however.
> >Think of all the possible yummy deadlocks with pthread_atfork. That is
> >not good. There is a very easy guideline: Do not mix threads/fork unless
> >you don't use any glib funtions in the forked child. Period. g_spawn
> >however looks save to use (instead of fork). We might want to add that
> >info regarding threads/forks somewhere in the GLib documentation.
> >
> >So can you be a little more elaborate, why your program is failing.
> >BTW easier to check than ("touch", "touch", "/tmp/testfile", NULL) would
> >be ("echo", "echo", "hello world", NULL).
> >
> >Remove the g_message calls from the child. They might block forever, if
> >fork was called, when the correspondiong mutex was just locked.
> >
> 
> Thanks for the insight.  In my testing, I never see "hello world."
> Basically, I just want to be able to run some scripts in different theards.
> It seems execlp(....) never exec-ed.  The OS is 6.2 of RedHat.

What happens, if you use g_spawn. It should work then. If is doesn't. I
would call it a bug. Try to find out, where it hangs, and always try the
last GLib version from CVS.

Bye,
Sebastian
-- 
Sebastian Wilhelmi
mailto:wilhelmi ira uka de
http://goethe.ira.uka.de/~wilhelmi





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