mon_pgrp = getpgrp(); /* save a copy of our process group */
/* Start command and wait for it to stop or exit */
- if (pipe(errpipe) == -1)
+ if (pipe2(errpipe, O_CLOEXEC) == -1)
sudo_fatal(U_("unable to create pipe"));
cmnd_pid = sudo_debug_fork();
if (cmnd_pid == -1) {
close(signal_pipe[0]);
close(signal_pipe[1]);
close(errpipe[0]);
- (void)fcntl(errpipe[1], F_SETFD, FD_CLOEXEC);
restore_signals();
/* setup tty and exec command */
/*
* We use a pipe to get errno if execve(2) fails in the child.
*/
- if (pipe(errpipe) == -1)
+ if (pipe2(errpipe, O_CLOEXEC) == -1)
sudo_fatal(U_("unable to create pipe"));
/*
close(errpipe[0]);
close(signal_pipe[0]);
close(signal_pipe[1]);
- (void)fcntl(errpipe[1], F_SETFD, FD_CLOEXEC);
exec_cmnd(details, errpipe[1]);
while (write(errpipe[1], &errno, sizeof(int)) == -1) {
if (errno != EINTR)