This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH] BZ# 18125: setcontext: Call exit, not _exit, after last linked context executes.
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: Rich Felker <dalias at libc dot org>
- Cc: GNU C Library <libc-alpha at sourceware dot org>, John David Anglin <dave dot anglin at bell dot net>, Marcus Shawcroft <marcus dot shawcroft at linaro dot org>, Chung-Lin Tang <chunglin_tang at mentor dot com>
- Date: Mon, 16 Mar 2015 11:24:24 -0400
- Subject: Re: [PATCH] BZ# 18125: setcontext: Call exit, not _exit, after last linked context executes.
- Authentication-results: sourceware.org; auth=none
- References: <55035374 dot 6060906 at redhat dot com> <20150314143055 dot GP23507 at brightrain dot aerifal dot cx>
On 03/14/2015 10:30 AM, Rich Felker wrote:
> On Fri, Mar 13, 2015 at 05:15:32PM -0400, Carlos O'Donell wrote:
>> There appears to be a discrepancy among the implementations
>> of setcontext with regards to the function called once the last
>> linked-to context has finished executing via setcontext.
>> The POSIX standard says:
>> If the uc_link member of the ucontext_t structure pointed to by
>> the ucp argument is equal to 0, then this context is the main
>> context, and the thread will exit when this context returns.
>> It says "exit" not "exit immediately" nor "exit without running
>> functions registered with atexit or on_exit."
> It says "the thread will exit", so you need to call pthread_exit, not
> _exit or exit. The latter cause the process to exit. Note that
> pthread_exit in the last thread results in exit being called.
That kind of change is outside the scope of this bug fix.
While in retrospect I agree with you, the interface in question is
deprecated and should not be used with pthreads, instead pthreads
should be used directly.
Thus we won't be 100% POSIX compliant until this gets fixed, but
we'll at least run registered exit functions.