summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorPhilip Guenthe <guenther@cvs.openbsd.org>2009-10-28 20:41:40 +0000
committerPhilip Guenthe <guenther@cvs.openbsd.org>2009-10-28 20:41:40 +0000
commitdac824dc8b08d86cd5ef1eb4a31dc0a514fabd8d (patch)
tree63b0cc7f3dc572292f5b9d4a5a7e827ba08bf766 /usr.bin
parentebbc25c6050cba15918ed3dcdb3a4c0e88d088e7 (diff)
Don't catch a signal if we inherited it as ignored. Instigated by
comments from Matt Fisher (mfisher_ix at maine.rr.com). ok otto@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/sort/sort.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/sort/sort.c b/usr.bin/sort/sort.c
index f8d94064533..99158ffc17c 100644
--- a/usr.bin/sort/sort.c
+++ b/usr.bin/sort/sort.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sort.c,v 1.37 2009/10/27 23:59:43 deraadt Exp $ */
+/* $OpenBSD: sort.c,v 1.38 2009/10/28 20:41:39 guenther Exp $ */
/*-
* Copyright (c) 1993
@@ -259,7 +259,7 @@ main(int argc, char *argv[])
outfile = outpath = toutpath;
} else if (!(ch = access(outpath, 0)) &&
strncmp(_PATH_DEV, outpath, 5)) {
- struct sigaction act;
+ struct sigaction oact, act;
int sigtable[] = {SIGHUP, SIGINT, SIGPIPE, SIGXCPU, SIGXFSZ,
SIGVTALRM, SIGPROF, 0};
int outfd;
@@ -284,7 +284,10 @@ main(int argc, char *argv[])
act.sa_flags = SA_RESTART;
act.sa_handler = onsig;
for (i = 0; sigtable[i]; ++i) /* always unlink toutpath */
- sigaction(sigtable[i], &act, 0);
+ if (sigaction(sigtable[i], NULL, &oact) < 0 ||
+ oact.sa_handler != SIG_IGN &&
+ sigaction(sigtable[i], &act, NULL) < 0)
+ err(2, "sigaction");
} else
outfile = outpath;
if (outfp == NULL && (outfp = fopen(outfile, "w")) == NULL)