diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2020-02-24 02:50:39 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2020-02-24 02:50:39 -0800 |
| commit | 327d65f7be9ef32b48fafa66aa58835115a91c95 (patch) | |
| tree | 838ccb403161cb4be53aab7d6f30ea0202b3df41 | |
| parent | 865092c656af70bd5317513d8e0ed87fdc1c9acd (diff) | |
Don't close and reopen tty files when running scripts.
| -rw-r--r-- | bb.c | 9 |
1 files changed, 2 insertions, 7 deletions
@@ -896,8 +896,6 @@ int run_script(bb_t *bb, const char *cmd) proc_t *proc = memcheck(calloc(1, sizeof(proc_t))); signal(SIGTTOU, SIG_IGN); if ((proc->pid = fork()) == 0) { - fclose(tty_out); tty_out = NULL; - fclose(tty_in); tty_in = NULL; pid_t pgrp = getpid(); (void)setpgid(0, pgrp); if (tcsetpgrp(STDIN_FILENO, pgrp)) @@ -916,11 +914,8 @@ int run_script(bb_t *bb, const char *cmd) setenv("BBCURSOR", bb->nfiles ? bb->files[bb->cursor]->fullname : "", 1); - int ttyout, ttyin; - ttyout = open("/dev/tty", O_RDWR); - ttyin = open("/dev/tty", O_RDONLY); - dup2(ttyout, STDOUT_FILENO); - dup2(ttyin, STDIN_FILENO); + dup2(fileno(tty_out), STDOUT_FILENO); + dup2(fileno(tty_in), STDIN_FILENO); execvp(args[0], args); err("Failed to execute command: '%s'", cmd); return -1; |
