summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2006-06-21 07:42:01 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2006-06-21 07:42:01 +0000
commitdb9d1e1c3fa9e2ad1bcc5f77c3e13ae23b4509a2 (patch)
tree64ae3f49d703e52fe19c906b6939108395cec05d
parent8ce952b092ccda5e22707116504f050027470c9b (diff)
avoid a race by installing SIGCHLD handler before fork() is called.
ok henning@ ckuethe@
-rw-r--r--usr.sbin/ntpd/ntp.c3
-rw-r--r--usr.sbin/ntpd/ntpd.c4
2 files changed, 4 insertions, 3 deletions
diff --git a/usr.sbin/ntpd/ntp.c b/usr.sbin/ntpd/ntp.c
index b970c1f9b80..631a1a8eda3 100644
--- a/usr.sbin/ntpd/ntp.c
+++ b/usr.sbin/ntpd/ntp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntp.c,v 1.87 2006/06/17 18:40:42 otto Exp $ */
+/* $OpenBSD: ntp.c,v 1.88 2006/06/21 07:42:00 otto Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -139,6 +139,7 @@ ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf)
signal(SIGINT, ntp_sighdlr);
signal(SIGPIPE, SIG_IGN);
signal(SIGHUP, SIG_IGN);
+ signal(SIGCHLD, SIG_DFL);
close(pipe_prnt[0]);
if ((ibuf_main = malloc(sizeof(struct imsgbuf))) == NULL)
diff --git a/usr.sbin/ntpd/ntpd.c b/usr.sbin/ntpd/ntpd.c
index b2e81ac57a1..88200cdcf17 100644
--- a/usr.sbin/ntpd/ntpd.c
+++ b/usr.sbin/ntpd/ntpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntpd.c,v 1.43 2006/06/17 18:40:42 otto Exp $ */
+/* $OpenBSD: ntpd.c,v 1.44 2006/06/21 07:42:00 otto Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -137,6 +137,7 @@ main(int argc, char *argv[])
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_chld) == -1)
fatal("socketpair");
+ signal(SIGCHLD, sighdlr);
/* fork child process */
chld_pid = ntp_main(pipe_chld, &conf);
@@ -144,7 +145,6 @@ main(int argc, char *argv[])
signal(SIGTERM, sighdlr);
signal(SIGINT, sighdlr);
- signal(SIGCHLD, sighdlr);
signal(SIGHUP, sighdlr);
close(pipe_chld[1]);