Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
spawn: another cleanups in spawn_and_give_stdout()
  • Loading branch information
perexg committed Nov 17, 2014
1 parent 2cee0bf commit 29ccb30
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/spawn.c
Expand Up @@ -340,11 +340,6 @@ spawn_and_give_stdout(const char *prog, char *argv[], int *rd, int redir_stderr)
close(fd[0]);
dup2(fd[1], 1);
close(fd[1]);
if (redir_stderr)
dup2(spawn_pipe_error.wr, 2);

for (f = 3; f < maxfd; f++)
close(f);

f = open("/dev/null", O_RDWR);
if(f == -1) {
Expand All @@ -354,12 +349,14 @@ spawn_and_give_stdout(const char *prog, char *argv[], int *rd, int redir_stderr)
}

dup2(f, 0);
if (!redir_stderr)
dup2(f, 2);
dup2(redir_stderr ? spawn_pipe_error.wr : f, 2);
close(f);

spawn_info("Executing \"%s\"\n", prog);

for (f = 3; f < maxfd; f++)
close(f);

execve(prog, argv, environ);
spawn_error("pid %d cannot execute %s -- %s\n",
getpid(), prog, strerror(errno));
Expand Down

0 comments on commit 29ccb30

Please sign in to comment.