diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2001-11-11 23:26:36 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2001-11-11 23:26:36 +0000 |
commit | 854e32bfa0ac46bd779092588acc3ad83723617f (patch) | |
tree | eb8c4c07328fbf5349c22f59ef1547c27bb5a29c /regress/lib/libc_r | |
parent | 4907cd2837006c10a4de5ff099eea656e5a089b8 (diff) |
signal race fixes
Diffstat (limited to 'regress/lib/libc_r')
-rw-r--r-- | regress/lib/libc_r/pause/pause.c | 9 | ||||
-rw-r--r-- | regress/lib/libc_r/signal/signal.c | 5 | ||||
-rw-r--r-- | regress/lib/libc_r/sigsuspend/sigsuspend.c | 17 | ||||
-rw-r--r-- | regress/lib/libc_r/sigwait/sigwait.c | 10 |
4 files changed, 31 insertions, 10 deletions
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[]) |