]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
terminal-util: explicitly reset cursor
authorLennart Poettering <lennart@poettering.net>
Thu, 15 May 2025 16:46:06 +0000 (18:46 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 16 May 2025 12:42:32 +0000 (21:42 +0900)
Apparently there are terminals where our usual reset is not enough to
turn the cursor back on. Hence do so explicitly.

Fixes: #22168
src/basic/terminal-util.c

index 7c900c267d4a721ec5f26dd5ea6e97f44561dd5c..5c78f1ec861e69c5ad505b692538159611095d69 100644 (file)
 #include "user-util.h"
 #include "utf8.h"
 
+#define ANSI_RESET_CURSOR                          \
+        "\033?25h"     /* turn on cursor */        \
+        "\033?12l"     /* reset cursor blinking */ \
+        "\033 1q"      /* reset cursor style */
+
 static volatile unsigned cached_columns = 0;
 static volatile unsigned cached_lines = 0;
 
@@ -856,6 +861,7 @@ int vt_disallocate(const char *tty_path) {
                 return fd2;
 
         return loop_write_full(fd2,
+                               ANSI_RESET_CURSOR
                                "\033[r"   /* clear scrolling region */
                                "\033[H"   /* move home */
                                "\033[3J"  /* clear screen including scrollback, requires Linux 2.6.40 */
@@ -972,6 +978,7 @@ static int terminal_reset_ansi_seq(int fd) {
                 return log_debug_errno(r, "Failed to set terminal to non-blocking mode: %m");
 
         k = loop_write_full(fd,
+                            ANSI_RESET_CURSOR
                             "\033[!p"      /* soft terminal reset */
                             "\033]104\007" /* reset colors */
                             "\033[?7h"     /* enable line-wrapping */