From c984f259aff5ec7451065519897af11fc078f54a Mon Sep 17 00:00:00 2001 From: ad Date: Fri, 30 Jan 2009 23:21:02 +0000 Subject: [PATCH] Make threaded programs die correctly: kill(getpid(), SIGFOO) -> raise(SIGFOO) --- lib/libc/misc/stack_protector.c | 6 +++--- lib/libc/stdlib/abort.c | 8 ++++---- lib/libc/thread-stub/thread-stub.c | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/libc/misc/stack_protector.c b/lib/libc/misc/stack_protector.c index 3cebf9ec2f71..431cc5725d8a 100644 --- a/lib/libc/misc/stack_protector.c +++ b/lib/libc/misc/stack_protector.c @@ -1,4 +1,4 @@ -/* $NetBSD: stack_protector.c,v 1.2 2008/06/03 19:22:37 ad Exp $ */ +/* $NetBSD: stack_protector.c,v 1.3 2009/01/30 23:21:02 ad Exp $ */ /* $OpenBSD: stack_protector.c,v 1.10 2006/03/31 05:34:44 deraadt Exp $ */ /* @@ -28,7 +28,7 @@ * */ #include -__RCSID("$NetBSD: stack_protector.c,v 1.2 2008/06/03 19:22:37 ad Exp $"); +__RCSID("$NetBSD: stack_protector.c,v 1.3 2009/01/30 23:21:02 ad Exp $"); #ifdef _LIBC #include "namespace.h" @@ -105,7 +105,7 @@ __fail(const char *msg) sa.sa_flags = 0; sa.sa_handler = SIG_DFL; (void)sigaction(SIGABRT, &sa, NULL); - (void)kill(getpid(), SIGABRT); + (void)raise(SIGABRT); _exit(127); } diff --git a/lib/libc/stdlib/abort.c b/lib/libc/stdlib/abort.c index 990a0115c74e..577bec167952 100644 --- a/lib/libc/stdlib/abort.c +++ b/lib/libc/stdlib/abort.c @@ -1,4 +1,4 @@ -/* $NetBSD: abort.c,v 1.12 2003/08/07 16:43:37 agc Exp $ */ +/* $NetBSD: abort.c,v 1.13 2009/01/30 23:21:03 ad Exp $ */ /* * Copyright (c) 1985, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)abort.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: abort.c,v 1.12 2003/08/07 16:43:37 agc Exp $"); +__RCSID("$NetBSD: abort.c,v 1.13 2009/01/30 23:21:03 ad Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -71,7 +71,7 @@ abort() (*__cleanup)(); } - (void)kill(getpid(), SIGABRT); + (void)raise(SIGABRT); /* * if SIGABRT ignored, or caught and the handler returns, do @@ -79,6 +79,6 @@ abort() */ (void)signal(SIGABRT, SIG_DFL); (void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL); - (void)kill(getpid(), SIGABRT); + (void)raise(SIGABRT); _exit(1); } diff --git a/lib/libc/thread-stub/thread-stub.c b/lib/libc/thread-stub/thread-stub.c index 28bf98092b32..29f49824f50f 100644 --- a/lib/libc/thread-stub/thread-stub.c +++ b/lib/libc/thread-stub/thread-stub.c @@ -1,7 +1,7 @@ -/* $NetBSD: thread-stub.c,v 1.20 2008/04/28 20:23:01 martin Exp $ */ +/* $NetBSD: thread-stub.c,v 1.21 2009/01/30 23:21:03 ad Exp $ */ /*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. + * Copyright (c) 2003, 2009 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -31,7 +31,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: thread-stub.c,v 1.20 2008/04/28 20:23:01 martin Exp $"); +__RCSID("$NetBSD: thread-stub.c,v 1.21 2009/01/30 23:21:03 ad Exp $"); #endif /* LIBC_SCCS and not lint */ /* @@ -53,7 +53,7 @@ __RCSID("$NetBSD: thread-stub.c,v 1.20 2008/04/28 20:23:01 martin Exp $"); extern int __isthreaded; -#define DIE() (void)kill(getpid(), SIGABRT) +#define DIE() (void)raise(SIGABRT) #define CHECK_NOT_THREADED_ALWAYS() \ do { \