mirror of
https://github.com/mpv-player/mpv
synced 2025-04-18 13:16:43 +00:00
input: don't make fd 0 nonblocking
Setting O_NONBLOCK on a file descriptor also affects all other fds that share the same underlying open file description, and in case of stdin such sharing is likely. Making stdin nonblocking can also make stdout nonblocking (they may be the same connection to a terminal), and it can also affect other processes (in "program1 | program2", the shell may give the same terminal connection to program1 as stdin and to program2 as stdout, thus program1 making its stdin nonblocking also turns program2's stdout nonblocking). To avoid these problems stop making fd 0 nonblocking. After the previous commit this should no longer cause problems as long as select() does not spuriously report the fd as readable.
This commit is contained in:
parent
82b8f89bae
commit
c3e46833c2
@ -4080,11 +4080,6 @@ current_module = "init_input";
|
||||
mpctx->input = mp_input_init(&opts->input);
|
||||
mpctx->key_fifo = mp_fifo_create(mpctx->input, opts);
|
||||
if(slave_mode) {
|
||||
#if USE_FD0_CMD_SELECT
|
||||
int flags = fcntl(0, F_GETFL);
|
||||
if (flags != -1)
|
||||
fcntl(0, F_SETFL, flags | O_NONBLOCK);
|
||||
#endif
|
||||
mp_input_add_cmd_fd(mpctx->input, 0,USE_FD0_CMD_SELECT,MP_INPUT_SLAVE_CMD_FUNC,NULL);
|
||||
}
|
||||
else if (opts->consolecontrols)
|
||||
|
@ -282,11 +282,6 @@ struct termios tio_new;
|
||||
tio_new.c_cc[VTIME] = 0;
|
||||
tcsetattr(0,TCSANOW,&tio_new);
|
||||
#endif
|
||||
/* Setting VMIN above should already make terminal non-blocking; but
|
||||
* that won't work if stdin is not a real terminal. */
|
||||
int flags = fcntl(0, F_GETFL);
|
||||
if (flags != -1)
|
||||
fcntl(0, F_SETFL, flags | O_NONBLOCK);
|
||||
getch2_status=1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user