summaryrefslogtreecommitdiff
path: root/usr.bin/script
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2015-07-19 06:12:07 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2015-07-19 06:12:07 +0000
commite736b3eb222fbec5845bddd515f55833098f1a19 (patch)
tree2af10d32280624455d3c26e6bbbe9ef1f7e99686 /usr.bin/script
parent1cd8f9817403a12558143ddef4a743f515431998 (diff)
SIGCHLD handler was established before forking into two processes.
As a result it also ran in the child (incorrect). ok miod
Diffstat (limited to 'usr.bin/script')
-rw-r--r--usr.bin/script/script.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/usr.bin/script/script.c b/usr.bin/script/script.c
index 83b3cce43cd..102141a0001 100644
--- a/usr.bin/script/script.c
+++ b/usr.bin/script/script.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: script.c,v 1.26 2015/03/15 00:41:28 millert Exp $ */
+/* $OpenBSD: script.c,v 1.27 2015/07/19 06:12:06 deraadt Exp $ */
/* $NetBSD: script.c,v 1.3 1994/12/21 08:55:43 jtc Exp $ */
/*
@@ -139,9 +139,6 @@ main(int argc, char *argv[])
bzero(&sa, sizeof sa);
sigemptyset(&sa.sa_mask);
- sa.sa_handler = finish;
- (void)sigaction(SIGCHLD, &sa, NULL);
-
sa.sa_handler = handlesigwinch;
sa.sa_flags = SA_RESTART;
(void)sigaction(SIGWINCH, &sa, NULL);
@@ -163,6 +160,11 @@ main(int argc, char *argv[])
doshell();
}
+ bzero(&sa, sizeof sa);
+ sigemptyset(&sa.sa_mask);
+ sa.sa_handler = finish;
+ (void)sigaction(SIGCHLD, &sa, NULL);
+
(void)fclose(fscript);
while (1) {
if (dead)
@@ -241,6 +243,11 @@ dooutput(void)
sa.sa_handler = scriptflush;
(void)sigaction(SIGALRM, &sa, NULL);
+ bzero(&sa, sizeof sa);
+ sigemptyset(&sa.sa_mask);
+ sa.sa_handler = SIG_IGN;
+ (void)sigaction(SIGCHLD, &sa, NULL);
+
value.it_interval.tv_sec = 30;
value.it_interval.tv_usec = 0;
value.it_value = value.it_interval;