From cd4713e96d599489d6a9f10cd4559495bacbc959 Mon Sep 17 00:00:00 2001 From: guenther Date: Sat, 10 Nov 2012 03:46:11 +0000 Subject: Per POSIX, fix raise() and abort() to send the signal to the current thread. Should make coredumps from abort() easier to debug too. ok kurt@ --- lib/libc/gen/raise.c | 6 ++++-- lib/libc/stdlib/abort.c | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/gen/raise.c b/lib/libc/gen/raise.c index 3ca6d3dfac6..d80513fc3fc 100644 --- a/lib/libc/gen/raise.c +++ b/lib/libc/gen/raise.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raise.c,v 1.5 2005/08/08 08:05:34 espie Exp $ */ +/* $OpenBSD: raise.c,v 1.6 2012/11/10 03:46:11 guenther Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -31,8 +31,10 @@ #include #include +int _thread_sys_getthrid(void); + int raise(int s) { - return(kill(getpid(), s)); + return(kill(_thread_sys_getthrid(), s)); } diff --git a/lib/libc/stdlib/abort.c b/lib/libc/stdlib/abort.c index 244e3b28aa2..4c8dc70a1d5 100644 --- a/lib/libc/stdlib/abort.c +++ b/lib/libc/stdlib/abort.c @@ -1,4 +1,4 @@ -/* $OpenBSD: abort.c,v 1.15 2007/09/03 14:40:16 millert Exp $ */ +/* $OpenBSD: abort.c,v 1.16 2012/11/10 03:46:11 guenther Exp $ */ /* * Copyright (c) 1985 Regents of the University of California. * All rights reserved. @@ -34,6 +34,8 @@ #include "thread_private.h" #include "atexit.h" +int _thread_sys_sigprocmask(int, const sigset_t *, sigset_t *); + void abort(void) { @@ -65,7 +67,7 @@ abort(void) } } - (void)kill(getpid(), SIGABRT); + (void)raise(SIGABRT); /* * if SIGABRT ignored, or caught and the handler returns, do @@ -73,6 +75,6 @@ abort(void) */ (void)signal(SIGABRT, SIG_DFL); (void)_thread_sys_sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL); - (void)kill(getpid(), SIGABRT); + (void)raise(SIGABRT); _exit(1); } -- cgit v1.2.3-59-g8ed1b