main: set $COLUMNS/$ROWS for PID 1 based on /dev/console data
authorLennart Poettering <lennart@poettering.net>
Wed, 17 Jul 2024 15:47:41 +0000 (17:47 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 19 Jul 2024 09:44:04 +0000 (11:44 +0200)
commitb4112281990839a28d56684c75a9b7d3631291cf
treede680d99fe9cadad0ea0df1d6c4d3eda82766e0d
parent0ea4198f0a9ef4aa2226b437bfa6e9a741ea99b0
main: set $COLUMNS/$ROWS for PID 1 based on /dev/console data

In PID 1 we write status information to /dev/console regularly, but we
cannot keep it open continously, due to the kernel's SAK logic (which
would kill PID 1 if user hits SAK). But closing/reopening it all the
time really sucks for tty types that have no window size management
(such as serial terminals/hvc0 and suchlike), because it also means the
TTY is fully closed most of the time, and that resets the window sizes
to 0/0.

Now, we reinitialize the window size on every reopen, but that is a bit
expensive for simple status output. Hence, cache the window size in the
usualy $COLUMNS/$ROWS environment variables. We don't inherit these to
our payloads anyway, hence these are free to us to use.
src/core/main.c