]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
nohup: simplify by using fcntl
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 17 Aug 2017 16:30:37 +0000 (09:30 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 17 Aug 2017 19:03:03 +0000 (12:03 -0700)
* src/nohup.c: Do not include cloexec.h.
(main): Use fcntl rather than dup + set_cloexec_flag.

src/nohup.c

index 1641dc784d42e60dbb353eda8eb126fcc6a9b641..53ec17f96c7a73b165144e9429da4696d731ec59 100644 (file)
@@ -24,7 +24,6 @@
 
 #include "system.h"
 
-#include "cloexec.h"
 #include "error.h"
 #include "filenamecat.h"
 #include "fd-reopen.h"
@@ -182,12 +181,8 @@ main (int argc, char **argv)
          if execve fails.  It's no big deal if this dup fails.  It might
          not change anything, and at worst, it'll lead to suppression of
          the post-failed-execve diagnostic.  */
-      saved_stderr_fd = dup (STDERR_FILENO);
-
-      if (0 <= saved_stderr_fd
-          && set_cloexec_flag (saved_stderr_fd, true) != 0)
-        error (exit_internal_failure, errno,
-               _("failed to set the copy of stderr to close on exec"));
+      saved_stderr_fd = fcntl (STDERR_FILENO, F_DUPFD_CLOEXEC,
+                               STDERR_FILENO + 1);
 
       if (!redirecting_stdout)
         error (0, 0,