Open controlling terminal for input when run in a script

This commit is contained in:
Arun Prakash Jana 2021-07-23 23:46:20 +05:30
parent 3a98dfb0b0
commit 25fab4cb2e
No known key found for this signature in database
GPG key ID: A75979F35C080412

View file

@ -8225,6 +8225,12 @@ int main(int argc, char *argv[])
return EXIT_FAILURE; return EXIT_FAILURE;
/* We return to tty */ /* We return to tty */
if (!isatty(STDOUT_FILENO)) {
fd = open(ctermid(NULL), O_RDWR, 0400);
dup2(fd, STDOUT_FILENO);
dup2(fd, STDIN_FILENO);
close(fd);
} else
dup2(STDOUT_FILENO, STDIN_FILENO); dup2(STDOUT_FILENO, STDIN_FILENO);
if (session) if (session)