diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-02-21 18:04:29 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-02-21 18:42:14 +0100 |
commit | d60473c7ba32f2325a13f0357b23fd8e25609650 (patch) | |
tree | fac01ab0f97f0a1f6e3085c899537944bf990b36 | |
parent | 210054d76cf4d294533aa09256d375e33b52569f (diff) |
ptyfwd: reset nonblocking mode
Apparently bash doesn't turn off non-blocking mode on stdin/stdout when
reading from it, so be nice to bash. Ideally bash would do this on its
own for robustness reasons, though.
https://bugs.freedesktop.org/show_bug.cgi?id=70622
-rw-r--r-- | src/shared/ptyfwd.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/shared/ptyfwd.c b/src/shared/ptyfwd.c index 72aa59efb7..d44d70bf9f 100644 --- a/src/shared/ptyfwd.c +++ b/src/shared/ptyfwd.c @@ -78,9 +78,9 @@ static int process_pty_loop(int master, sigset_t *mask, pid_t kill_pid, int sign assert(kill_pid == 0 || kill_pid > 1); assert(signo >= 0 && signo < _NSIG); - fd_nonblock(STDIN_FILENO, 1); - fd_nonblock(STDOUT_FILENO, 1); - fd_nonblock(master, 1); + fd_nonblock(STDIN_FILENO, true); + fd_nonblock(STDOUT_FILENO, true); + fd_nonblock(master, true); signal_fd = signalfd(-1, mask, SFD_NONBLOCK|SFD_CLOEXEC); if (signal_fd < 0) { @@ -376,6 +376,11 @@ int process_pty(int master, sigset_t *mask, pid_t kill_pid, int signo) { if (saved_stdin) tcsetattr(STDIN_FILENO, TCSANOW, &saved_stdin_attr); + /* STDIN/STDOUT should not be nonblocking normally, so let's + * unconditionally reset it */ + fd_nonblock(STDIN_FILENO, false); + fd_nonblock(STDOUT_FILENO, false); + return r; } |