Browse Source

avoid a race by installing SIGCHLD handler before fork() is called.

ok henning@ ckuethe@
OPENBSD_4_0
otto 18 years ago
parent
commit
8746f65b53
2 changed files with 4 additions and 3 deletions
  1. +2
    -1
      src/usr.sbin/ntpd/ntp.c
  2. +2
    -2
      src/usr.sbin/ntpd/ntpd.c

+ 2
- 1
src/usr.sbin/ntpd/ntp.c View File

@ -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)


+ 2
- 2
src/usr.sbin/ntpd/ntpd.c View File

@ -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]);


Loading…
Cancel
Save