From: Roy Marples Date: Thu, 23 May 2013 18:58:28 +0000 (+0000) Subject: Don't directly close stderr X-Git-Tag: v5.99.7~36 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6e7265d52769bda513a9f13804e3cb487fe9e83b;p=thirdparty%2Fdhcpcd.git Don't directly close stderr --- diff --git a/dhcpcd.c b/dhcpcd.c index 545af79d..b0f0cbfc 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -970,8 +970,15 @@ main(int argc, char **argv) if (options & DHCPCD_DEBUG) setlogmask(LOG_UPTO(LOG_DEBUG)); - if (options & DHCPCD_QUIET) - close(STDERR_FILENO); + if (options & DHCPCD_QUIET) { + i = open(_PATH_DEVNULL, O_RDWR); + if (i == -1) + syslog(LOG_ERR, "%s: open: %m", __func__); + else { + dup2(i, STDERR_FILENO); + close(i); + } + } if (!(options & (DHCPCD_TEST | DHCPCD_DUMPLEASE))) { /* If we have any other args, we should run as a single dhcpcd