nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit c60d3bbb97b9dee1cfa15542fc7ef62ac3ac1446
parent 90d4b51837895d955a718b766d591baaff4d2d88
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sun, 17 Nov 2019 08:20:32 +0100

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

Diffstat:
Msrc/text.c | 11+++++------
1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/text.c b/src/text.c @@ -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]);