mirror of
https://github.com/sheumann/hush.git
synced 2024-11-18 17:10:36 +00:00
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>
This commit is contained in:
parent
29f3526048
commit
438b4ac286
@ -16,7 +16,7 @@ int FAST_FUNC xgetpty(char *line)
|
||||
|
||||
#if ENABLE_FEATURE_DEVPTS
|
||||
p = open("/dev/ptmx", O_RDWR);
|
||||
if (p > 0) {
|
||||
if (p >= 0) {
|
||||
grantpt(p); /* chmod+chown corresponding slave pty */
|
||||
unlockpt(p); /* (what does this do?) */
|
||||
# ifndef HAVE_PTSNAME_R
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user