From: Zbigniew Jędrzejewski-Szmek Date: Tue, 20 Aug 2019 19:11:59 +0000 (+0200) Subject: shutdown: fix shutdown with console=null X-Git-Tag: 050~171 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b91d3f15bf0477fac5f53164ccdc9c88f872854c;p=thirdparty%2Fdracut.git shutdown: fix shutdown with console=null C.f. https://github.com/systemd/systemd/issues/13332. --- diff --git a/modules.d/99shutdown/shutdown.sh b/modules.d/99shutdown/shutdown.sh index e3884a882..a30a126fa 100755 --- a/modules.d/99shutdown/shutdown.sh +++ b/modules.d/99shutdown/shutdown.sh @@ -6,7 +6,13 @@ # Harald Hoyer ACTION="$1" -[ -w /dev/console ] && exec >/dev/console 2>>/dev/console +# Before trying to use /dev/console, verify that it exists, +# and that it can actually be used. When console=null is used, +# echo will fail. We do the check in a subshell, because otherwise +# the process will be killed when when running as PID 1. +[ -w /dev/console ] && \ + ( echo /dev/null ) && \ + exec >/dev/console 2>>/dev/console export TERM=linux export PATH=/usr/sbin:/usr/bin:/sbin:/bin