mirror of
git://git.sv.gnu.org/coreutils
synced 2026-06-05 07:12:30 -04:00
Include "cloexec.h".
(main): Set the copy of stderr to close on exec.
This commit is contained in:
@@ -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"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user