File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 601601
602602% %%%%
603603
604+ ifdef([[[NOSPELLCHECK]]], [[[
605+ \pdfbookmark [1]{pthread\_ atfork}{pthreadatfork}
606+ ]]])
607+
604608\begin {slide }
605609\sltitle {\funnm {fork}() and POSIX threads}
606610\prgchars
645649child), you will avoid such deadlocks. That is because when locking mutexes in
646650the \emph {\texttt {pre-fork } } handler, other threads are still running so the
647651mutexes held by them should be released eventually (usually each thread exits a
648- critical section in a short time in well written code). Example:
649- \example {pthreads/atfork.c}. For more on this topic, see [Butenhof].
652+ critical section in a short time in well written code).
653+ \item This scheme will only work if the \emph {\texttt {pre-fork } } handler
654+ maintains the same locking protocol/ordering as is used in the
655+ application/library. Sometimes that is just not possible due to multiple complex
656+ orderings in place. Very often \funnm {fork}() is called just as a means for
657+ later \funnm {exec}(). In such case the programmer would be better off using
658+ \funnm {posix\_ spawn}().
659+ \item Example: \example {pthreads/atfork.c}
660+ \item For more on this topic, see [Butenhof].
650661\item See page \pageref {MUTEXES } on why mutexes locked in other threads on
651662\funnm {fork}() stay locked forever.
652663\end {itemize }
You can’t perform that action at this time.
0 commit comments