File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change 618618\item \label {ATFORK } You can use \funnm {pthread\_ atfork}() to set handlers that
619619are executed before \funnm {fork}() is called in the parent, and then after
620620\funnm {fork}() is called both in the parent and its child. Such handlers are
621- very useful who use \funnm {fork}() not only for a wrapper around \funnm {exec}().
621+ very useful when \funnm {fork}() is used not only as a wrapper around
622+ \funnm {exec}().
622623After \funnm {fork}(), all variables in the child are in the state as in the
623- parent, so if a thread not propagated to the child held a mutex (see page
624- \pageref {MUTEXES }), the mutex stays
624+ parent, so if a thread not present to the child held a mutex in the parent
625+ (see page \pageref {MUTEXES }), the mutex stays
625626locked in the child, and trying to lock in the child will lead to a deadlock.
626- However, if the parent in the \emph {\texttt {pre-fork } } handler locks all the
627- mutexes, and then unlocks them in the \emph {\texttt {post-fork } } handler (both
627+ However, if the parent locks all the mutexes in the \emph {\texttt {pre-fork } }
628+ handler and then unlocks them in the \emph {\texttt {post-fork } } handler (both
628629for the parent and the child), you will avoid such deadlocks. When locking
629630mutexes in the \emph {\texttt {pre-fork } } handler, other threads are still running
630631so the mutexes held by them can be released (usually each thread exits a
You can’t perform that action at this time.
0 commit comments