aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/reader.cpp
diff options
context:
space:
mode:
authorGravatar Kurtis Rader <krader@skepticism.us>2015-12-04 18:51:06 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2015-12-08 21:01:31 -0800
commit16c34b387ffd0e9e8340b065959d4b6f0cf4f6dc (patch)
tree9fe6976a225f7eba55163d4da77cdb2a1c67be30 /src/reader.cpp
parentd65c63322ef52443b372c3c49dbd3584596fed6b (diff)
Ensure interactive tty modes are set ASAP
It is critical that we ensure our interactive tty modes are in effect at the earliest possible moment. This achieves that goal and is harmless if stdin is not tied to a tty. The reason for doing this is to ensure that \r characters are not converted to \n if we're running on the slave side of a pty controlled by a program like tmux that is stuffing keystrokes into the pty before we issue our first prompt.
Diffstat (limited to 'src/reader.cpp')
-rw-r--r--src/reader.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/reader.cpp b/src/reader.cpp
index df196492..fa3d887d 100644
--- a/src/reader.cpp
+++ b/src/reader.cpp
@@ -1045,6 +1045,15 @@ void reader_init()
shell_modes.c_cc[VDSUSP] = _POSIX_VDISABLE;
#endif
#endif
+
+ // We don't use term_steal because this can fail if fd 0 isn't associated
+ // with a tty and this function is run regardless of whether stdin is tied
+ // to a tty. This is harmless in that case. We do it unconditionally
+ // because disabling ICRNL mode (see above) needs to be done at the
+ // earliest possible moment. Doing it here means it will be done within
+ // approximately 1 ms of the start of the shell rather than 250 ms (or
+ // more) when reader_interactive_init is eventually called.
+ tcsetattr(STDIN_FILENO, TCSANOW,&shell_modes);
}