This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] BZ# 18125: setcontext: Call exit, not _exit, after last linked context executes.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]