|
|
2aacef |
From c5e4b6b9b2a1dea35f58f3e1c3313bca76a90162 Mon Sep 17 00:00:00 2001
|
|
|
2aacef |
From: Ray Strode <rstrode@redhat.com>
|
|
|
2aacef |
Date: Wed, 30 Nov 2022 14:07:29 -0500
|
|
|
2aacef |
Subject: [PATCH] terminal-util: Set OPOST when setting ONLCR
|
|
|
2aacef |
|
|
|
2aacef |
reset_terminal_fd sets certain minimum required terminal attributes
|
|
|
2aacef |
that systemd relies on.
|
|
|
2aacef |
|
|
|
2aacef |
One of those attributes is `ONLCR` which ensures that when a new line
|
|
|
2aacef |
is sent to the terminal, that the cursor not only moves to the next
|
|
|
2aacef |
line, but also moves to the very beginning of that line.
|
|
|
2aacef |
|
|
|
2aacef |
In order for `ONLCR` to work, the terminal needs to perform output
|
|
|
2aacef |
post-processing. That requires an additional attribute, `OPOST`,
|
|
|
2aacef |
which reset_terminal_fd currently fails to ensure is set.
|
|
|
2aacef |
|
|
|
2aacef |
In most cases `OPOST` (and `ONLCR` actually) are both set anyway, so
|
|
|
2aacef |
it's not an issue, but it could be a problem if, e.g., the terminal was
|
|
|
2aacef |
put in raw mode by a program and the program unexpectedly died before
|
|
|
2aacef |
restoring settings.
|
|
|
2aacef |
|
|
|
2aacef |
This commit ensures when `ONLCR` is set `OPOST` is set too, which is
|
|
|
2aacef |
the only thing that really makes sense to do.
|
|
|
2aacef |
|
|
|
2aacef |
(cherry picked from commit 9fe26523a189435d75b9d745188e09c17928d89e)
|
|
|
2aacef |
|
|
|
2aacef |
Related: #2138081
|
|
|
2aacef |
---
|
|
|
2aacef |
src/basic/terminal-util.c | 2 +-
|
|
|
2aacef |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
2aacef |
|
|
|
2aacef |
diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c
|
|
|
2aacef |
index 0c092597eb..a75234f354 100644
|
|
|
2aacef |
--- a/src/basic/terminal-util.c
|
|
|
2aacef |
+++ b/src/basic/terminal-util.c
|
|
|
2aacef |
@@ -269,7 +269,7 @@ int reset_terminal_fd(int fd, bool switch_to_text) {
|
|
|
2aacef |
|
|
|
2aacef |
termios.c_iflag &= ~(IGNBRK | BRKINT | ISTRIP | INLCR | IGNCR | IUCLC);
|
|
|
2aacef |
termios.c_iflag |= ICRNL | IMAXBEL | IUTF8;
|
|
|
2aacef |
- termios.c_oflag |= ONLCR;
|
|
|
2aacef |
+ termios.c_oflag |= ONLCR | OPOST;
|
|
|
2aacef |
termios.c_cflag |= CREAD;
|
|
|
2aacef |
termios.c_lflag = ISIG | ICANON | IEXTEN | ECHO | ECHOE | ECHOK | ECHOCTL | ECHOPRT | ECHOKE;
|
|
|
2aacef |
|