]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Include "cloexec.h".
authorJim Meyering <jim@meyering.net>
Wed, 3 Mar 2004 22:00:20 +0000 (22:00 +0000)
committerJim Meyering <jim@meyering.net>
Wed, 3 Mar 2004 22:00:20 +0000 (22:00 +0000)
(main): Set the copy of stderr to close on exec.

src/nohup.c

index d524424ec610474aebfc4f80d45fee6edba88950..c7caa7f01bc22465c015f4f505c3b1ee7097d60e 100644 (file)
@@ -28,6 +28,7 @@
 #include "long-options.h"
 #include "path-concat.h"
 #include "quote.h"
+#include "cloexec.h"
 
 #define PROGRAM_NAME "nohup"
 
@@ -148,6 +149,10 @@ main (int argc, char **argv)
         the post-failed-execve diagnostic.  */
       saved_stderr_fd = dup (STDERR_FILENO);
 
+      if (set_cloexec_flag (saved_stderr_fd, 1) == -1)
+       error (NOHUP_FAILURE, errno,
+              _("failed to set the copy of stderr to close on exec"));
+
       if (dup2 (fd, STDERR_FILENO) == -1)
        error (NOHUP_FAILURE, errno, _("failed to redirect standard error"));
     }