diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2001-10-24 17:28:17 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2001-10-24 17:28:17 +0000 |
commit | b63d94eeb32cdb0f74aee4d49dd45475cb621be8 (patch) | |
tree | 11d5d97b952a624af67c4317d58d6f556f430da9 /usr.sbin/cron/popen.c | |
parent | 3304ae07e128acca74b601e043df6f543a59509f (diff) |
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.
Diffstat (limited to 'usr.sbin/cron/popen.c')
-rw-r--r-- | usr.sbin/cron/popen.c | 14 |
1 files changed, 7 insertions, 7 deletions
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]); |