mirror of
https://github.com/troglobit/finit.git
synced 2026-10-17 10:49:34 +00:00
Fix issue with VINTR, VEOF et al not being restored after boot
On Alpine Linux 3.6 the tcsetattr() calls failed. This turned out to be a deeply rooted issue not limited to just musl libc. The workaround is to call tcsetattr() in several rounds. In particular the modem signals, c_cflag bits, always fail, so we take a bet on Linux having set up the terminals (hope as a strategy) and ignore that problem, for now. Also, use TCSAFLUSH with tcsetattr(), that seems to work better and is what BusyBox stty use. The local CTL() macro is replaced with CTL() from ttydefaults.h, which exists also in musl libc. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
83078d1947
commit
484aa0ba97
3 files changed
+19
-20
No files matched your search
+4
-5
@@ -41,7 +41,6 @@
|
||||
#define _PATH_LOGIN "/bin/login"
|
||||
#endif
|
||||
|
||||
#define CTL(x) ((x) ^ 0100)
|
||||
#define print(s) (void)write(STDOUT_FILENO, s, strlen(s))
|
||||
|
||||
|
||||
@@ -164,7 +163,7 @@ static void do_getty(char *tty, char *name, size_t len)
|
||||
|
||||
np = name;
|
||||
while ((ch = readch(tty)) != '\n') {
|
||||
if (ch == CTL('U')) {
|
||||
if (ch == CTRL('U')) {
|
||||
while (np > name) {
|
||||
(void)write(1, "\b \b", 3);
|
||||
np--;
|
||||
@@ -290,9 +289,9 @@ int sh(char *tty)
|
||||
/* Reenable Ctrl-D and Ctrl-C, and ... */
|
||||
if (!tcgetattr(STDIN_FILENO, &term)) {
|
||||
term.c_lflag |= ISIG;
|
||||
term.c_cc[VEOF] = CTL('D');
|
||||
term.c_cc[VINTR] = CTL('C');
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &term);
|
||||
term.c_cc[VEOF] = CEOF;
|
||||
term.c_cc[VINTR] = CINTR;
|
||||
tcsetattr(STDIN_FILENO, TCSAFLUSH, &term);
|
||||
}
|
||||
|
||||
/* ... unblock signals in general */
|
||||
|
||||
Reference in new issue
Block a user