This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Calling other functions while concurrently calling exit?
- From: Rich Felker <dalias at aerifal dot cx>
- To: OndÅej BÃlka <neleai at seznam dot cz>
- Cc: Andreas Schwab <schwab at linux-m68k dot org>, Carlos O'Donell <carlos at redhat dot com>, GNU C Library <libc-alpha at sourceware dot org>, Torvald Riegel <triegel at redhat dot com>
- Date: Sat, 19 Sep 2015 10:26:37 -0400
- Subject: Re: Calling other functions while concurrently calling exit?
- Authentication-results: sourceware.org; auth=none
- References: <55FCD13B dot 8030000 at redhat dot com> <87fv2aoqfe dot fsf at igel dot home> <20150919101041 dot GA15324 at domone>
On Sat, Sep 19, 2015 at 12:10:41PM +0200, OndÅej BÃlka wrote:
> On Sat, Sep 19, 2015 at 08:48:21AM +0200, Andreas Schwab wrote:
> > "Carlos O'Donell" <carlos@redhat.com> writes:
> >
> > > Is it spelled out anywhere in POSIX or ISO C that calling
> > > other functions concurrently with exit is going to result
> > > in undefined behaviour?
> >
> > exit must be thread-safe, except that calling it more than once is
> > undefined.
> >
> Wait, we don't do sane thing and first cancel all other threads before doing anything?
You cannot cancel threads that are currently running code that was not
designed to be cancellable. Doing so is extremely dangerous.
> How otherwise we would run tls destructors in context of correct thread?
TLS destructors only run when the thread exit, either by being the one
to call exit or by exiting as a thread (e.g. pthread_exit). This is
all specified.
Rich