From: Paul Pluzhnikov <ppluzhnikov@earthlink.net>
Subject: Re: fork() problem
Date: Fri, 30 Aug 2002 15:04:30 GMT [thread overview]
Message-ID: <m3adn45s4k.fsf@salmon.parasoft.com> (raw)
In-Reply-To: roma-122E2D.16285830082002@news.gamma.ru
Roman Prokhorov <roma@stalker.gamma.ru> writes:
> Still don't beleive it. Why fork() checks the stdio locks? It doesn't
> print anything by itself.
From Linux "man pthread_atfork":
To understand the purpose of pthread_atfork, recall that
fork(2) duplicates the whole memory space, including mutexes in
their current locking state, but only the calling thread: other
threads are not running in the child process. Thus, if a mutex
is locked by a thread other than the thread calling fork, that
mutex will remain locked forever in the child process, possibly
blocking the execution of the child process. To avoid this,
install handlers with pthread_atfork as follows: the prepare handler
locks the global mutexes (in locking order), and the parent
and child handlers unlock them (in reverse order). Alternatively,
prepare and parent can be set to NULL and child to a function that
calls pthread_mutex_init on the global mutexes.
Apparently Tru64 choose the first alternative ;-(
Cheers,
--
In order to understand recursion you must first understand recursion.
next prev parent reply other threads:[~2002-08-30 15:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-28 23:13 fork() problem Roman Prokhorov
2002-08-29 4:04 ` Paul Pluzhnikov
2002-08-29 15:00 ` Roman Prokhorov
2002-08-30 0:05 ` Paul Pluzhnikov
2002-08-30 12:28 ` Roman Prokhorov
2002-08-30 15:04 ` Paul Pluzhnikov [this message]
2002-08-30 16:41 ` Roman Prokhorov
2002-08-30 18:04 ` Paul Pluzhnikov
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox