[PATCH] BZ# 18125: setcontext: Call exit, not _exit, after last linked context executes.
Rich Felker
dalias@libc.org
Sat Mar 14 14:31:00 GMT 2015
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.
Rich
More information about the Libc-alpha
mailing list