crash-handler: Call vhangup on /dev/console before spawning crash shell

When pid 1 crashes, the getty unit for the console will happily keep
running which means we end up with two shells competing for the same
tty. Let's call vhangup on /dev/console to kill every other process
attached to the console before we spawn the crash shell. The getty
units have Restart=always but lucky for us, pid 1 just crashed in fire
and flames so it isn't actually able to restart the getty unit.
This commit is contained in:
Daan De Meyer
2024-08-07 21:24:57 +02:00
parent 2561e2a356
commit bc3477fdc5
3 changed files with 14 additions and 0 deletions
+1
View File
@@ -165,6 +165,7 @@ _noreturn_ static void crash(int sig, siginfo_t *siginfo, void *context) {
"MESSAGE_ID=" SD_MESSAGE_CRASH_SHELL_FORK_FAILED_STR);
else if (pid == 0) {
(void) setsid();
(void) terminal_vhangup("/dev/console");
(void) make_console_stdio();
(void) rlimit_nofile_safe();
(void) execle("/bin/sh", "/bin/sh", NULL, environ);