Re: using pthreads with fork() in linux
- From: "Maxim Yegorushkin" <maxim.yegorushkin@xxxxxxxxx>
- Date: 30 May 2006 02:45:25 -0700
Arnold Hendriks wrote:
"Jelte" <jelte.werkhoven@xxxxxxxxxxxxxxx> wrote in message
news:1148974504.450517.232000@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
For one, you should only use async-signal-safe functions after fork(), until
Elena wrote:
Hi, I have the following situation:
in the main() I create a thread by using pthread_create(), then my
main() forks,
the child program performs some action and exits. The parent waits for
it with "waitpid()".
you exec().
This is wrong. You are probably talking about vfork().
If you happen to fork while another thread still holds an
important lock, that thread wouldn't exist in the forked copy and the lock
would never be released inside the child, causing a deadlock
This is why there is pthread_atfork.
http://www.opengroup.org/onlinepubs/009695399/functions/pthread_atfork.html
.
- Follow-Ups:
- Re: using pthreads with fork() in linux
- From: Arnold Hendriks
- Re: using pthreads with fork() in linux
- References:
- using pthreads with fork() in linux
- From: Elena
- Re: using pthreads with fork() in linux
- From: Jelte
- Re: using pthreads with fork() in linux
- From: Arnold Hendriks
- using pthreads with fork() in linux
- Prev by Date: Re: using pthreads with fork() in linux
- Next by Date: Re: using pthreads with fork() in linux
- Previous by thread: Re: using pthreads with fork() in linux
- Next by thread: Re: using pthreads with fork() in linux
- Index(es):