Skip to content

Commit a6d862a

Browse files
author
Vladimir Kotal
committed
fix wording
1 parent 3d8fe9c commit a6d862a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

threads.tex

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -618,13 +618,14 @@
618618
\item \label{ATFORK} You can use \funnm{pthread\_atfork}() to set handlers that
619619
are 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}().
622623
After \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
625626
locked 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
628629
for the parent and the child), you will avoid such deadlocks. When locking
629630
mutexes in the \emph{\texttt{pre-fork}} handler, other threads are still running
630631
so the mutexes held by them can be released (usually each thread exits a

0 commit comments

Comments
 (0)