aboutsummaryrefslogtreecommitdiff
path: root/init
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2019-12-02 16:39:54 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2019-12-02 16:39:54 +0100
commit113c776f4d2ce4ead7c2d11a3ca62adeec9a2e34 (patch)
tree86ebfbdf565a9c2fe07b564c6e7e565281426b5a /init
parent259747caa7d86a5a46013b80a19b2ee2d4e0a73b (diff)
downloadbusybox-113c776f4d2ce4ead7c2d11a3ca62adeec9a2e34.tar.gz
init: if tcgetattr() fails, don't even try to tcsetattr()
function old new delta set_sane_term 111 114 +3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'init')
-rw-r--r--init/init.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/init/init.c b/init/init.c
index 0f3c5fa4d..db1d99add 100644
--- a/init/init.c
+++ b/init/init.c
@@ -145,13 +145,6 @@
# include <sys/ucontext.h>
#endif
-/* Used only for sanitizing purposes in set_sane_term() below. On systems where
- * the baud rate is stored in a separate field, we can safely disable them. */
-#ifndef CBAUD
-# define CBAUD 0
-# define CBAUDEX 0
-#endif
-
/* Was a CONFIG_xxx option. A lot of people were building
* not fully functional init by switching it on! */
#define DEBUG_INIT 0
@@ -347,7 +340,8 @@ static void set_sane_term(void)
{
struct termios tty;
- tcgetattr(STDIN_FILENO, &tty);
+ if (tcgetattr(STDIN_FILENO, &tty) != 0)
+ return;
/* set control chars */
tty.c_cc[VINTR] = 3; /* C-c */
@@ -365,10 +359,15 @@ static void set_sane_term(void)
#endif
/* Make it be sane */
+/* On systems where the baud rate is stored in a separate field, we can safely disable these. */
+#ifndef CBAUD
+# define CBAUD 0
+# define CBAUDEX 0
+#endif
+/* Added CRTSCTS to fix Debian bug 528560 */
#ifndef CRTSCTS
# define CRTSCTS 0
#endif
- /* added CRTSCTS to fix Debian bug 528560 */
tty.c_cflag &= CBAUD | CBAUDEX | CSIZE | CSTOPB | PARENB | PARODD | CRTSCTS;
tty.c_cflag |= CREAD | HUPCL | CLOCAL;