From b91d3f15bf0477fac5f53164ccdc9c88f872854c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 20 Aug 2019 21:11:59 +0200 Subject: [PATCH] shutdown: fix shutdown with console=null C.f. https://github.com/systemd/systemd/issues/13332. --- modules.d/99shutdown/shutdown.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 -- 2.47.3