From 438b4ac2860f4aec5b5fb82c47f75a0cb80d9cb4 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 16 Mar 2014 12:34:53 +0100 Subject: script: make it work even if fd 0 is closed Testcase: script -q -c "echo hey" /dev/null 0>&- Signed-off-by: Denys Vlasenko --- util-linux/script.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'util-linux') diff --git a/util-linux/script.c b/util-linux/script.c index 8fb991d..abcd73b 100644 --- a/util-linux/script.c +++ b/util-linux/script.c @@ -77,8 +77,15 @@ int script_main(int argc UNUSED_PARAM, char **argv) if (!(opt & OPT_q)) { printf("Script started, file is %s\n", fname); } + shell = get_shell_name(); + /* Some people run "script ... 0>&-". + * Our code assumes that STDIN_FILENO != pty. + * Ensure STDIN_FILENO is not closed: + */ + bb_sanitize_stdio(); + pty = xgetpty(pty_line); /* get current stdin's tty params */ -- cgit v1.1