tweaks: don't do in the parent something that only the child needs

master
Benno Schulenberg 2019-11-17 08:20:32 +01:00
parent 90d4b51837
commit c60d3bbb97
1 changed files with 5 additions and 6 deletions

View File

@ -947,7 +947,6 @@ bool execute_command(const char *command)
/* The pipes through which text will be written and read. */
const bool should_pipe = (command[0] == '|');
FILE *stream;
const char *shellenv;
struct sigaction oldaction, newaction;
/* Original and temporary handlers for SIGINT. */
@ -958,13 +957,13 @@ bool execute_command(const char *command)
return FALSE;
}
/* Check which shell to use. If none is specified, use /bin/sh. */
shellenv = getenv("SHELL");
if (shellenv == NULL)
shellenv = (char *)"/bin/sh";
/* Fork a child process to run the command in. */
if ((pid_of_command = fork()) == 0) {
const char *shellenv = getenv("SHELL");
if (shellenv == NULL)
shellenv = (char *)"/bin/sh";
/* Child: close the unused read end of the output pipe. */
close(from_fd[0]);