]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pid1: use $COLUMNS info in status_vprintf() 33707/head
authorLennart Poettering <lennart@poettering.net>
Wed, 17 Jul 2024 15:56:01 +0000 (17:56 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 19 Jul 2024 09:44:05 +0000 (11:44 +0200)
This way, we can work around the fact that "struct winsize" for
/dev/console might not be initialized the moment we open the device.

src/core/show-status.c

index 57ad4db30b5adc433b0305d5227cb64075108026..7c7c10f96367ff66d6cdcba4abbdde027252a0c9 100644 (file)
@@ -72,8 +72,14 @@ int status_vprintf(const char *status, ShowStatusFlags flags, const char *format
                 int c;
 
                 c = fd_columns(fd);
-                if (c <= 0)
-                        c = 80;
+                if (c <= 0) {
+                        const char *env = getenv("COLUMNS");
+                        if (env)
+                                (void) safe_atoi(env, &c);
+
+                        if (c <= 0)
+                                c = 80;
+                }
 
                 sl = status ? strlen(status_indent) : 0;