]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Don't directly close stderr
authorRoy Marples <roy@marples.name>
Thu, 23 May 2013 18:58:28 +0000 (18:58 +0000)
committerRoy Marples <roy@marples.name>
Thu, 23 May 2013 18:58:28 +0000 (18:58 +0000)
dhcpcd.c

index 545af79d7973b9df639e668e2ef9fddcd22cee75..b0f0cbfcd3ea39a58b379713240c9df927969193 100644 (file)
--- 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