summaryrefslogtreecommitdiff
path: root/src/nohup.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2004-03-03 22:00:20 +0000
committerJim Meyering <jim@meyering.net>2004-03-03 22:00:20 +0000
commit8d0b9f87dd5032e705a16fd7c3875cfb4e32b26e (patch)
treeafa4327719f29e0097a1e64d16e6fdbd51929141 /src/nohup.c
parent2389b81eefed29cb2117a77397257cf0b936f769 (diff)
downloadcoreutils-8d0b9f87dd5032e705a16fd7c3875cfb4e32b26e.tar.xz
Include "cloexec.h".
(main): Set the copy of stderr to close on exec.
Diffstat (limited to 'src/nohup.c')
-rw-r--r--src/nohup.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/nohup.c b/src/nohup.c
index d524424ec..c7caa7f01 100644
--- a/src/nohup.c
+++ b/src/nohup.c
@@ -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"));
}