1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

test: kill plymouthd after initrd transition if it's still running

Until now using the INTERACTIVE_DEBUG=yes stuff together with sanitizers
was almost impossible, since the console kept eating up our inputs or
not responding at all. After a painful day of debugging I noticed that
if we use a shell script in the initrd -> root transition, we might end up
with a plymouthd still running, which kept screwing with the tty.

E.g. with initrd -> wrapper -> systemd transition, where the `wrapper`
is a simple script:

```
exec -- /usr/lib/systemd/systemd "$@"
```

we'd end up with a stray plymouthd process after the bootup:

```
 1     0     440       2  20   0      0     0 worker I    ?          0:00 [kworker/5:2-ata_sff]
 1     0     453       2  20   0      0     0 worker I    ?          0:00 [kworker/9:2-rcu_gp]
 5     0     456       1  20   0   7252  1960 do_epo S    ?          0:00 @usr/sbin/plymouthd --mode=boot --pid-file=/run/plymouth/pid --attach-to-session
```

After killing it, the tty works finally as expected.
This commit is contained in:
Frantisek Sumsal 2022-09-05 21:02:25 +02:00 committed by Yu Watanabe
parent bad57012af
commit 5c08efee03

View File

@ -179,6 +179,7 @@ BASICTOOLS=(
head
ionice
ip
killall
ldd
ln
loadkeys
@ -1794,6 +1795,26 @@ install_debug_tools() {
image_install resize
echo "resize" >>"$initdir/etc/profile"
fi
# Sometimes we might end up with plymouthd still running (especially
# with the initrd -> asan_wrapper -> systemd transition), which will eat
# our inputs and make debugging via tty impossible. Let's fix this by
# killing plymouthd explicitly for the interactive sessions.
# Note: we can't use pkill/pidof/etc. here due to a bug in libasan, see:
# - https://github.com/llvm/llvm-project/issues/49223
# - https://bugzilla.redhat.com/show_bug.cgi?id=2098125
local plymouth_unit="${initdir:?}/etc/systemd/system/kill-plymouth.service"
cat >"$plymouth_unit" <<EOF
[Unit]
After=multi-user.target
[Service]
ExecStart=sh -c 'killall --verbose plymouthd || :'
[Install]
WantedBy=multi-user.target
EOF
"${SYSTEMCTL:?}" enable --root "${initdir:?}" kill-plymouth.service
fi
}