RE: Nagios and threads
From: Daniel Eischen (eischen_at_vigrid.com)
Date: Wed, 22 Jun 2005 10:25:19 -0400 (EDT) To: Norbert Koch <NKoch@demig.de>
On Wed, 22 Jun 2005, Norbert Koch wrote:
> > [snip]
> > > at least some assumptions that the child won't be
> > > doing much before
> > > execing or exiting. (But Im sure one of the
> > The child process should be able to call any system
> > calls it likes -without assuming that pthreads from
> > the parent process have been copied over to the child
> > process. I spose most implementations support that.
> > regards
> > -kamal
> >From "Programming with POSIX Threads" [David R. Butenhof]:
> ... Avoid using fork in a threaded program (if you can)
> unless you intend to exec a new program immediately
> ... Pthreads does not "terminate" the other threads
> in a forked process. ... They simple cease to exist.
> ... The state of mutexes is not affected by a fork. If
> it was locked in the parent it is locked in the child!
Yes, and realize that both libc and libpthread are consumers
themselves of mutexes (and CVs). Also, some system calls
are wrapped by libpthread to provide cancellation points.
Unless you exec after the fork, you may be relying on
inconsistent mutex state.
-- DE _______________________________________________ firstname.lastname@example.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "email@example.com"