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: Rich Felker <dalias at libc dot org>
- To: Carlos O'Donell <carlos at redhat dot com>
- 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: Sat, 14 Mar 2015 10:30:55 -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>
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.