summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2001-11-11 23:26:36 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2001-11-11 23:26:36 +0000
commit854e32bfa0ac46bd779092588acc3ad83723617f (patch)
treeeb8c4c07328fbf5349c22f59ef1547c27bb5a29c
parent4907cd2837006c10a4de5ff099eea656e5a089b8 (diff)
signal race fixes
-rw-r--r--regress/lib/libc/setjmp/jmptest.c10
-rw-r--r--regress/lib/libc_r/pause/pause.c9
-rw-r--r--regress/lib/libc_r/signal/signal.c5
-rw-r--r--regress/lib/libc_r/sigsuspend/sigsuspend.c17
-rw-r--r--regress/lib/libc_r/sigwait/sigwait.c10
-rw-r--r--regress/lib/libpthread/pause/pause.c9
-rw-r--r--regress/lib/libpthread/signal/signal.c5
-rw-r--r--regress/lib/libpthread/sigsuspend/sigsuspend.c17
-rw-r--r--regress/lib/libpthread/sigwait/sigwait.c10
-rw-r--r--regress/sys/arch/i386/ldt/testldt.c4
-rw-r--r--regress/sys/kern/unfdpass/unfdpass.c4
11 files changed, 73 insertions, 27 deletions
diff --git a/regress/lib/libc/setjmp/jmptest.c b/regress/lib/libc/setjmp/jmptest.c
index aec1a9e782a..de6e70d9f6a 100644
--- a/regress/lib/libc/setjmp/jmptest.c
+++ b/regress/lib/libc/setjmp/jmptest.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: jmptest.c,v 1.4 2001/01/29 02:05:45 niklas Exp $ */
+/* $OpenBSD: jmptest.c,v 1.5 2001/11/11 23:26:35 deraadt Exp $ */
/* $NetBSD: jmptest.c,v 1.2 1995/01/01 20:55:35 jtc Exp $ */
/*
@@ -70,9 +70,11 @@ aborthandler(signo)
{
if (expectsignal)
- exit(0);
- else
- errx(1, "kill(SIGABRT) succeeded");
+ _exit(0);
+ else {
+ warnx("kill(SIGABRT) succeeded");
+ _exit(1);
+ }
}
int
diff --git a/regress/lib/libc_r/pause/pause.c b/regress/lib/libc_r/pause/pause.c
index 8185e7ca2d0..20a49f061a6 100644
--- a/regress/lib/libc_r/pause/pause.c
+++ b/regress/lib/libc_r/pause/pause.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pause.c,v 1.1 2001/08/15 14:37:12 fgsch Exp $ */
+/* $OpenBSD: pause.c,v 1.2 2001/11/11 23:26:35 deraadt Exp $ */
/*
* Copyright (c) 1993, 1994, 1995, 1996 by Chris Provenzano and contributors,
* proven@mit.edu All rights reserved.
@@ -48,7 +48,12 @@ void
handler(sig)
int sig;
{
- printf("%s\n", strsignal(sig));
+ int save_errno = errno;
+ char buf[8192];
+
+ snprintf(buf, sizeof buf, "%s\n", strsignal(sig));
+ write(STDOUT_FILENO, buf, strlen(buf));
+ errno = save_errno;
}
int
diff --git a/regress/lib/libc_r/signal/signal.c b/regress/lib/libc_r/signal/signal.c
index 4955dd86f83..2d79cf2e08a 100644
--- a/regress/lib/libc_r/signal/signal.c
+++ b/regress/lib/libc_r/signal/signal.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: signal.c,v 1.2 2001/11/03 04:33:48 marc Exp $ */
+/* $OpenBSD: signal.c,v 1.3 2001/11/11 23:26:35 deraadt Exp $ */
/* David Leonard <d@openbsd.org>, 2001. Public Domain. */
/*
@@ -31,9 +31,12 @@ void
handler(sig)
int sig;
{
+ int save_errno = errno;
+
alarmed = 1;
alarm(1);
signal(SIGALRM, handler);
+ errno = save_errno;
}
int
diff --git a/regress/lib/libc_r/sigsuspend/sigsuspend.c b/regress/lib/libc_r/sigsuspend/sigsuspend.c
index df3b990dafb..86a9ff959ef 100644
--- a/regress/lib/libc_r/sigsuspend/sigsuspend.c
+++ b/regress/lib/libc_r/sigsuspend/sigsuspend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigsuspend.c,v 1.1 2001/08/15 14:37:13 fgsch Exp $ */
+/* $OpenBSD: sigsuspend.c,v 1.2 2001/11/11 23:26:35 deraadt Exp $ */
/*
* Copyright (c) 1998 Daniel M. Eischen <eischen@vigrid.com>
* All rights reserved.
@@ -93,6 +93,8 @@ sigsuspender (void *arg)
static void
sighandler (int signo)
{
+ int save_errno = errno;
+ char buf[8192];
sigset_t set;
pthread_t self;
@@ -107,14 +109,19 @@ sighandler (int signo)
if (self == suspender_tid) {
sigfifo[fifo_depth] = signo;
fifo_depth++;
- printf (" -> Suspender thread signal handler caught "
+ snprintf(buf, sizeof buf,
+ " -> Suspender thread signal handler caught "
"signal %d (%s)\n", signo, strsignal(signo));
+ write(STDOUT_FILENO, buf, strlen(buf));
sigprocmask (SIG_SETMASK, NULL, &set);
ASSERT(set == suspender_mask);
- }
- else
- printf (" -> Main thread signal handler caught "
+ } else {
+ snprintf(buf, sizeof buf,
+ " -> Main thread signal handler caught "
"signal %d (%s)\n", signo, strsignal(signo));
+ write(STDOUT_FILENO, buf, strlen(buf));
+ }
+ errno = save_errno;
}
diff --git a/regress/lib/libc_r/sigwait/sigwait.c b/regress/lib/libc_r/sigwait/sigwait.c
index a166eaf2a1e..70ed4f576cc 100644
--- a/regress/lib/libc_r/sigwait/sigwait.c
+++ b/regress/lib/libc_r/sigwait/sigwait.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigwait.c,v 1.1 2001/08/15 14:37:16 fgsch Exp $ */
+/* $OpenBSD: sigwait.c,v 1.2 2001/11/11 23:26:35 deraadt Exp $ */
/*
* Copyright (c) 1998 Daniel M. Eischen <eischen@vigrid.com>
* All rights reserved.
@@ -80,11 +80,17 @@ sigwaiter (void *arg)
static void
sighandler (int signo)
{
- printf (" -> Signal handler caught signal %d (%s) in thread %p\n",
+ int save_errno = errno;
+ char buf[8192];
+
+ snprintf(buf, sizeof buf,
+ " -> Signal handler caught signal %d (%s) in thread %p\n",
signo, strsignal(signo), pthread_self());
+ write(STDOUT_FILENO, buf, strlen(buf));
if ((signo >= 0) && (signo <= NSIG))
sigcounts[signo]++;
+ errno = save_errno;
}
int main (int argc, char *argv[])
diff --git a/regress/lib/libpthread/pause/pause.c b/regress/lib/libpthread/pause/pause.c
index 8185e7ca2d0..20a49f061a6 100644
--- a/regress/lib/libpthread/pause/pause.c
+++ b/regress/lib/libpthread/pause/pause.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pause.c,v 1.1 2001/08/15 14:37:12 fgsch Exp $ */
+/* $OpenBSD: pause.c,v 1.2 2001/11/11 23:26:35 deraadt Exp $ */
/*
* Copyright (c) 1993, 1994, 1995, 1996 by Chris Provenzano and contributors,
* proven@mit.edu All rights reserved.
@@ -48,7 +48,12 @@ void
handler(sig)
int sig;
{
- printf("%s\n", strsignal(sig));
+ int save_errno = errno;
+ char buf[8192];
+
+ snprintf(buf, sizeof buf, "%s\n", strsignal(sig));
+ write(STDOUT_FILENO, buf, strlen(buf));
+ errno = save_errno;
}
int
diff --git a/regress/lib/libpthread/signal/signal.c b/regress/lib/libpthread/signal/signal.c
index 4955dd86f83..2d79cf2e08a 100644
--- a/regress/lib/libpthread/signal/signal.c
+++ b/regress/lib/libpthread/signal/signal.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: signal.c,v 1.2 2001/11/03 04:33:48 marc Exp $ */
+/* $OpenBSD: signal.c,v 1.3 2001/11/11 23:26:35 deraadt Exp $ */
/* David Leonard <d@openbsd.org>, 2001. Public Domain. */
/*
@@ -31,9 +31,12 @@ void
handler(sig)
int sig;
{
+ int save_errno = errno;
+
alarmed = 1;
alarm(1);
signal(SIGALRM, handler);
+ errno = save_errno;
}
int
diff --git a/regress/lib/libpthread/sigsuspend/sigsuspend.c b/regress/lib/libpthread/sigsuspend/sigsuspend.c
index df3b990dafb..86a9ff959ef 100644
--- a/regress/lib/libpthread/sigsuspend/sigsuspend.c
+++ b/regress/lib/libpthread/sigsuspend/sigsuspend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigsuspend.c,v 1.1 2001/08/15 14:37:13 fgsch Exp $ */
+/* $OpenBSD: sigsuspend.c,v 1.2 2001/11/11 23:26:35 deraadt Exp $ */
/*
* Copyright (c) 1998 Daniel M. Eischen <eischen@vigrid.com>
* All rights reserved.
@@ -93,6 +93,8 @@ sigsuspender (void *arg)
static void
sighandler (int signo)
{
+ int save_errno = errno;
+ char buf[8192];
sigset_t set;
pthread_t self;
@@ -107,14 +109,19 @@ sighandler (int signo)
if (self == suspender_tid) {
sigfifo[fifo_depth] = signo;
fifo_depth++;
- printf (" -> Suspender thread signal handler caught "
+ snprintf(buf, sizeof buf,
+ " -> Suspender thread signal handler caught "
"signal %d (%s)\n", signo, strsignal(signo));
+ write(STDOUT_FILENO, buf, strlen(buf));
sigprocmask (SIG_SETMASK, NULL, &set);
ASSERT(set == suspender_mask);
- }
- else
- printf (" -> Main thread signal handler caught "
+ } else {
+ snprintf(buf, sizeof buf,
+ " -> Main thread signal handler caught "
"signal %d (%s)\n", signo, strsignal(signo));
+ write(STDOUT_FILENO, buf, strlen(buf));
+ }
+ errno = save_errno;
}
diff --git a/regress/lib/libpthread/sigwait/sigwait.c b/regress/lib/libpthread/sigwait/sigwait.c
index a166eaf2a1e..70ed4f576cc 100644
--- a/regress/lib/libpthread/sigwait/sigwait.c
+++ b/regress/lib/libpthread/sigwait/sigwait.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sigwait.c,v 1.1 2001/08/15 14:37:16 fgsch Exp $ */
+/* $OpenBSD: sigwait.c,v 1.2 2001/11/11 23:26:35 deraadt Exp $ */
/*
* Copyright (c) 1998 Daniel M. Eischen <eischen@vigrid.com>
* All rights reserved.
@@ -80,11 +80,17 @@ sigwaiter (void *arg)
static void
sighandler (int signo)
{
- printf (" -> Signal handler caught signal %d (%s) in thread %p\n",
+ int save_errno = errno;
+ char buf[8192];
+
+ snprintf(buf, sizeof buf,
+ " -> Signal handler caught signal %d (%s) in thread %p\n",
signo, strsignal(signo), pthread_self());
+ write(STDOUT_FILENO, buf, strlen(buf));
if ((signo >= 0) && (signo <= NSIG))
sigcounts[signo]++;
+ errno = save_errno;
}
int main (int argc, char *argv[])
diff --git a/regress/sys/arch/i386/ldt/testldt.c b/regress/sys/arch/i386/ldt/testldt.c
index ec33335f430..60fea3cc943 100644
--- a/regress/sys/arch/i386/ldt/testldt.c
+++ b/regress/sys/arch/i386/ldt/testldt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: testldt.c,v 1.4 2001/05/11 15:51:59 art Exp $ */
+/* $OpenBSD: testldt.c,v 1.5 2001/11/11 23:26:35 deraadt Exp $ */
/* $NetBSD: testldt.c,v 1.4 1995/04/20 22:42:38 cgd Exp $ */
#include <stdio.h>
@@ -137,7 +137,7 @@ print_ldt(union descriptor *dp)
static void busfault(int signal, int code, struct sigcontext *sc)
{
fprintf(stderr, "\nbus fault - investigate.\n");
- exit(1);
+ _exit(1);
}
static void usage(int status)
diff --git a/regress/sys/kern/unfdpass/unfdpass.c b/regress/sys/kern/unfdpass/unfdpass.c
index fe518c3f3ad..fac10349be9 100644
--- a/regress/sys/kern/unfdpass/unfdpass.c
+++ b/regress/sys/kern/unfdpass/unfdpass.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: unfdpass.c,v 1.2 2001/01/29 02:05:57 niklas Exp $ */
+/* $OpenBSD: unfdpass.c,v 1.3 2001/11/11 23:26:35 deraadt Exp $ */
/* $NetBSD: unfdpass.c,v 1.3 1998/06/24 23:51:30 thorpej Exp $ */
/*-
@@ -240,9 +240,11 @@ void
catch_sigchld(sig)
int sig;
{
+ int save_errno = errno;
int status;
(void) wait(&status);
+ errno = save_errno;
}
void