From b63d94eeb32cdb0f74aee4d49dd45475cb621be8 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 24 Oct 2001 17:28:17 +0000 Subject: When becoming a daemon, dup stdin, stdout, and stderr to /dev/null Change an unsafe vfork() to fork() Fix dup2() usage--must check for oldd == newd case and no need to close oldd Fixes annoying messages from sendmail about stdout being closed. --- usr.sbin/cron/popen.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'usr.sbin/cron/popen.c') diff --git a/usr.sbin/cron/popen.c b/usr.sbin/cron/popen.c index bac4b39c765..2e922a11067 100644 --- a/usr.sbin/cron/popen.c +++ b/usr.sbin/cron/popen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: popen.c,v 1.11 2001/10/01 19:19:09 millert Exp $ */ +/* $OpenBSD: popen.c,v 1.12 2001/10/24 17:28:16 millert Exp $ */ /* * Copyright (c) 1988, 1993, 1994 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)popen.c 8.3 (Berkeley) 4/6/94"; #else -static char rcsid[] = "$OpenBSD: popen.c,v 1.11 2001/10/01 19:19:09 millert Exp $"; +static char rcsid[] = "$OpenBSD: popen.c,v 1.12 2001/10/24 17:28:16 millert Exp $"; #endif #endif /* not lint */ @@ -153,15 +153,15 @@ cron_popen(program, type, e) } closelog(); if (*type == 'r') { - if (pdes[1] != STDOUT_FILENO) { - dup2(pdes[1], STDOUT_FILENO); + if (pdes[1] != STDOUT) { + dup2(pdes[1], STDOUT); (void)close(pdes[1]); } - dup2(STDOUT_FILENO, STDERR_FILENO); /* stderr too! */ + dup2(STDOUT, STDERR); /* stderr too! */ (void)close(pdes[0]); } else { - if (pdes[0] != STDIN_FILENO) { - dup2(pdes[0], STDIN_FILENO); + if (pdes[0] != STDIN) { + dup2(pdes[0], STDIN); (void)close(pdes[0]); } (void)close(pdes[1]); -- cgit v1.2.3