Fix Ctrl-C, and signals in general, on "logins" in nologin mode

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2018-01-16 16:25:11 +01:00
parent 37e420bd35
commit abbc0a1d5c
2 changed files with 12 additions and 1 deletions
-1
View File
@@ -21,7 +21,6 @@ can also be used.
Before Release
--------------
* Ctrl-C does not work properly on "logins" in `nologin` mode
* Running `initctl restart foo` in the background blocks
+12
View File
@@ -252,6 +252,7 @@ int sh(char *tty)
NULL
};
size_t len;
struct termios term;
/* Detach from initial controlling TTY */
vhangup();
@@ -282,6 +283,17 @@ int sh(char *tty)
snprintf(arg0, len, "-%s", _PATH_BSHELL);
args[0] = arg0;
/* 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);
}
/* ... unblock signals in general */
sig_unblock();
return execv(_PATH_BSHELL, args);
}