]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ptyfwd: reset colors when we exit the pty forwarding logic
authorLennart Poettering <lennart@poettering.net>
Wed, 20 Dec 2023 10:58:35 +0000 (11:58 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 20 Dec 2023 14:49:09 +0000 (15:49 +0100)
Just in case there was still a color set, make sure to reset things.

src/shared/ptyfwd.c

index 4950932a96789a2e2f4c3c59c8455b4a52004c44..d01d1b1094f9a2565b629880bf8ce00c1c0f4232 100644 (file)
@@ -19,6 +19,7 @@
 #include "alloc-util.h"
 #include "errno-util.h"
 #include "fd-util.h"
+#include "io-util.h"
 #include "log.h"
 #include "macro.h"
 #include "ptyfwd.h"
@@ -96,6 +97,10 @@ static void pty_forward_disconnect(PTYForward *f) {
 
                 /* STDIN/STDOUT should not be non-blocking normally, so let's reset it */
                 (void) fd_nonblock(f->output_fd, false);
+
+                if (colors_enabled())
+                        (void) loop_write(f->output_fd, ANSI_NORMAL ANSI_ERASE_TO_END_OF_LINE, SIZE_MAX);
+
                 if (f->close_output_fd)
                         f->output_fd = safe_close(f->output_fd);
         }