From cb5b9388dad6d0524322d45eafaa7b5d7b00b554 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 27 Dec 2003 07:38:25 +0000 Subject: Update. 2003-12-23 Jakub Jelinek * sysdeps/unix/sysv/linux/raise.c (raise): Protect pid = selftid setting with __ASSUME_TGKILL || defined __NR_tgkill. If pid is 0, set it to selftid. * sysdeps/unix/sysv/linux/getpid.c (really_getpid): Make inline. Don't set self->pid but self->tid. If self->pid == 0 and self->tid != 0, return self->tid without doing a syscall. * descr.h (struct pthread): Move pid field after tid. * Makefile (tests): Add tst-raise1. * tst-raise1.c: New file. --- nptl/sysdeps/unix/sysv/linux/raise.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'nptl/sysdeps/unix/sysv/linux/raise.c') diff --git a/nptl/sysdeps/unix/sysv/linux/raise.c b/nptl/sysdeps/unix/sysv/linux/raise.c index 268ba87b29..ac54fa217e 100644 --- a/nptl/sysdeps/unix/sysv/linux/raise.c +++ b/nptl/sysdeps/unix/sysv/linux/raise.c @@ -44,17 +44,19 @@ raise (sig) #endif THREAD_SETMEM (pd, tid, selftid); +#if __ASSUME_TGKILL || defined __NR_tgkill /* We do not set the PID field in the TID here since we might be called from a signal handler while the thread executes fork. */ pid = selftid; +#endif } #if __ASSUME_TGKILL || defined __NR_tgkill else /* raise is an async-safe function. It could be called while the fork function temporarily invalidated the PID field. Adjust for that. */ - if (__builtin_expect (pid < 0, 0)) - pid = -pid; + if (__builtin_expect (pid <= 0, 0)) + pid = pid == 0 ? selftid : -pid; #endif #if __ASSUME_TGKILL -- cgit v1.2.3