From 8746f65b538a6fafc357f56a282f1f13471095cd Mon Sep 17 00:00:00 2001 From: otto <> Date: Wed, 21 Jun 2006 07:42:00 +0000 Subject: [PATCH] avoid a race by installing SIGCHLD handler before fork() is called. ok henning@ ckuethe@ --- src/usr.sbin/ntpd/ntp.c | 3 ++- src/usr.sbin/ntpd/ntpd.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/usr.sbin/ntpd/ntp.c b/src/usr.sbin/ntpd/ntp.c index b970c1f9..631a1a8e 100644 --- a/src/usr.sbin/ntpd/ntp.c +++ b/src/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 @@ -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/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c index b2e81ac5..88200cdc 100644 --- a/src/usr.sbin/ntpd/ntpd.c +++ b/src/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 @@ -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]);