diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c index e77e54a..8441845 100644 --- a/src/thread/pthread_create.c +++ b/src/thread/pthread_create.c @@ -97,6 +97,7 @@ void __do_cleanup_pop(struct __ptcb *cb) static int start(void *p) { + void* ret; pthread_t self = p; if (self->startlock[0]) { __wait(self->startlock, 0, 1, 1); @@ -109,7 +110,12 @@ static int start(void *p) if (self->unblock_cancel) __syscall(SYS_rt_sigprocmask, SIG_UNBLOCK, SIGPT_SET, 0, _NSIG/8); - pthread_exit(self->start(self->start_arg)); + ret = self->start(self->start_arg); + /* POSIX states: The thread exits (that is, calls pthread_exit()) + According to the documentation on Linux a return from the + function doesn't count as such an exit. */ + self->cancelbuf = 0; + pthread_exit(ret); return 0; }