Don't close and reopen tty files when running scripts.
This commit is contained in:
parent
865092c656
commit
327d65f7be
9
bb.c
9
bb.c
@ -896,8 +896,6 @@ int run_script(bb_t *bb, const char *cmd)
|
|||||||
proc_t *proc = memcheck(calloc(1, sizeof(proc_t)));
|
proc_t *proc = memcheck(calloc(1, sizeof(proc_t)));
|
||||||
signal(SIGTTOU, SIG_IGN);
|
signal(SIGTTOU, SIG_IGN);
|
||||||
if ((proc->pid = fork()) == 0) {
|
if ((proc->pid = fork()) == 0) {
|
||||||
fclose(tty_out); tty_out = NULL;
|
|
||||||
fclose(tty_in); tty_in = NULL;
|
|
||||||
pid_t pgrp = getpid();
|
pid_t pgrp = getpid();
|
||||||
(void)setpgid(0, pgrp);
|
(void)setpgid(0, pgrp);
|
||||||
if (tcsetpgrp(STDIN_FILENO, 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);
|
setenv("BBCURSOR", bb->nfiles ? bb->files[bb->cursor]->fullname : "", 1);
|
||||||
|
|
||||||
int ttyout, ttyin;
|
dup2(fileno(tty_out), STDOUT_FILENO);
|
||||||
ttyout = open("/dev/tty", O_RDWR);
|
dup2(fileno(tty_in), STDIN_FILENO);
|
||||||
ttyin = open("/dev/tty", O_RDONLY);
|
|
||||||
dup2(ttyout, STDOUT_FILENO);
|
|
||||||
dup2(ttyin, STDIN_FILENO);
|
|
||||||
execvp(args[0], args);
|
execvp(args[0], args);
|
||||||
err("Failed to execute command: '%s'", cmd);
|
err("Failed to execute command: '%s'", cmd);
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user