From: Jim Meyering Date: Wed, 3 Mar 2004 22:00:20 +0000 (+0000) Subject: Include "cloexec.h". X-Git-Tag: v5.2.1~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d0b9f87dd5032e705a16fd7c3875cfb4e32b26e;p=thirdparty%2Fcoreutils.git Include "cloexec.h". (main): Set the copy of stderr to close on exec. --- diff --git a/src/nohup.c b/src/nohup.c index d524424ec6..c7caa7f01b 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")); }