bsod: install the signal handler only just before we need it

Otherwise we might get stuck in sd_journal_wait(), since it handles
EINTR internally.

Resolves: #30084
This commit is contained in:
Frantisek Sumsal
2023-11-21 16:58:33 +00:00
committed by Luca Boccassi
parent 027b34d9fc
commit 7ec22d7d4b
2 changed files with 15 additions and 1 deletions
+2 -1
View File
@@ -285,7 +285,6 @@ static int run(int argc, char *argv[]) {
log_parse_environment();
sigbus_install();
assert_se(sigaction_many(&nop_sigaction, SIGTERM, SIGINT) >= 0);
r = parse_argv(argc, argv);
if (r <= 0)
@@ -300,6 +299,8 @@ static int run(int argc, char *argv[]) {
return 0;
}
assert_se(sigaction_many(&nop_sigaction, SIGTERM, SIGINT) >= 0);
r = display_emergency_message_fullscreen((const char*) message);
if (r < 0)
return log_error_errno(r, "Failed to display emergency message on terminal: %m");
+13
View File
@@ -88,3 +88,16 @@ systemctl daemon-reload
systemctl start systemd-bsod
systemd-cat -p emerg echo "Service emergency message"
vcs_dump_and_check "Service emergency message"
systemctl stop systemd-bsod
# Wipe the journal
journalctl --vacuum-size=1 --rotate
(! journalctl -q -b -p emerg --grep .)
# Same as above, but make sure the service responds to signals even when there are
# no "emerg" messages, see systemd/systemd#30084
(! systemctl is-active systemd-bsod)
systemctl start systemd-bsod
timeout 5s bash -xec 'until systemctl is-active systemd-bsod; do sleep .5; done'
timeout 5s systemctl stop systemd-bsod
timeout 5s bash -xec 'while systemctl is-active systemd-bsod; do sleep .5; done'