diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2014-03-16 12:34:53 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2014-03-16 12:34:53 +0100 |
| commit | 438b4ac2860f4aec5b5fb82c47f75a0cb80d9cb4 (patch) | |
| tree | 83dd96e62dfe975fa9ea3f738fe32e220862b2fa /util-linux | |
| parent | 29f352604868c5d17c81948ea30e332491cecada (diff) | |
| download | busybox-w32-438b4ac2860f4aec5b5fb82c47f75a0cb80d9cb4.tar.gz busybox-w32-438b4ac2860f4aec5b5fb82c47f75a0cb80d9cb4.tar.bz2 busybox-w32-438b4ac2860f4aec5b5fb82c47f75a0cb80d9cb4.zip | |
script: make it work even if fd 0 is closed
Testcase:
script -q -c "echo hey" /dev/null 0>&-
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux')
| -rw-r--r-- | util-linux/script.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/util-linux/script.c b/util-linux/script.c index 8fb991d15..abcd73bff 100644 --- a/util-linux/script.c +++ b/util-linux/script.c | |||
| @@ -77,8 +77,15 @@ int script_main(int argc UNUSED_PARAM, char **argv) | |||
| 77 | if (!(opt & OPT_q)) { | 77 | if (!(opt & OPT_q)) { |
| 78 | printf("Script started, file is %s\n", fname); | 78 | printf("Script started, file is %s\n", fname); |
| 79 | } | 79 | } |
| 80 | |||
| 80 | shell = get_shell_name(); | 81 | shell = get_shell_name(); |
| 81 | 82 | ||
| 83 | /* Some people run "script ... 0>&-". | ||
| 84 | * Our code assumes that STDIN_FILENO != pty. | ||
| 85 | * Ensure STDIN_FILENO is not closed: | ||
| 86 | */ | ||
| 87 | bb_sanitize_stdio(); | ||
| 88 | |||
| 82 | pty = xgetpty(pty_line); | 89 | pty = xgetpty(pty_line); |
| 83 | 90 | ||
| 84 | /* get current stdin's tty params */ | 91 | /* get current stdin's tty params */ |
