From: Michael Snyder <msnyder@specifix.com>
To: Daniel Jacobowitz <drow@false.org>
Cc: Pedro Alves <pedro@codesourcery.com>, gdb-patches@sourceware.org
Subject: Re: [non-stop] 08/10 linux native support
Date: Wed, 09 Jul 2008 03:55:00 -0000 [thread overview]
Message-ID: <1215575706.3549.140.camel@localhost.localdomain> (raw)
In-Reply-To: <20080709034706.GA21192@caradoc.them.org>
On Tue, 2008-07-08 at 23:47 -0400, Daniel Jacobowitz wrote:
> On Tue, Jul 08, 2008 at 08:25:36PM -0700, Michael Snyder wrote:
> > Fork is undefined in a multi-threaded program.
>
> According to what? Not POSIX - otherwise there wouldn't be
> pthread_atfork.
>
> I think even vfork is valid in multithreaded programs; in any case, it
> behaves sensibly with NPTL.
Well, I should perhaps say for, is *not well* defined in a
multi-threaded
program -- at least not defined consistently. I had to research this
at my last job but one, and it was very difficult to find anything that
definitively says that it is UN-defined... but try to find Posix
explicitly saying what *should* happen if a multi-threaded program
forks.
Here's IEEE std 1003.1:
A process shall be created with a single thread. If a multi-threaded
process calls fork(), the new process shall contain a replica of the
calling thread and its entire address space, possibly including the
states of mutexes and other resources. Consequently, to avoid errors,
the child process may only execute async-signal-safe operations until
such time as one of the exec functions is called. [THR] [Option Start]
Fork handlers may be established by means of the pthread_atfork()
function in order to maintain application invariants across fork()
calls. [Option End]
The issue is that only the thread that actually calls fork()
will be duplicated in the child, but the mutexes (which may have
been held by another thread) will be duplicated, and therefore
the child may deadlock.
next prev parent reply other threads:[~2008-07-09 3:55 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-15 21:10 Pedro Alves
2008-06-25 21:17 ` Daniel Jacobowitz
2008-06-25 22:03 ` Pedro Alves
2008-06-25 22:12 ` Pedro Alves
2008-06-25 22:52 ` Daniel Jacobowitz
2008-06-25 23:08 ` Daniel Jacobowitz
2008-07-02 3:35 ` Pedro Alves
2008-07-07 18:20 ` Daniel Jacobowitz
2008-07-09 3:25 ` Michael Snyder
2008-07-09 3:47 ` Daniel Jacobowitz
2008-07-09 3:55 ` Michael Snyder [this message]
2008-07-09 7:55 ` Mark Kettenis
2008-07-09 7:56 ` Mark Kettenis
2008-07-10 15:28 ` Pedro Alves
2008-07-10 17:15 ` Daniel Jacobowitz
2008-07-10 18:01 ` Pedro Alves
2008-07-10 19:59 ` Daniel Jacobowitz
2008-07-10 21:51 ` Pedro Alves
2008-07-10 22:15 ` Daniel Jacobowitz
2008-07-10 23:01 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1215575706.3549.140.camel@localhost.localdomain \
--to=msnyder@specifix.com \
--cc=drow@false.org \
--cc=gdb-patches@sourceware.org \
--cc=pedro@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox