[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/5] nohup: simplify by using fcntl
From: |
Paul Eggert |
Subject: |
[PATCH 5/5] nohup: simplify by using fcntl |
Date: |
Thu, 17 Aug 2017 12:04:56 -0700 |
* src/nohup.c: Do not include cloexec.h.
(main): Use fcntl rather than dup + set_cloexec_flag.
---
src/nohup.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/src/nohup.c b/src/nohup.c
index 1641dc784..53ec17f96 100644
--- a/src/nohup.c
+++ b/src/nohup.c
@@ -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,
--
2.13.5