Merge pull request #30538 from poettering/ptyfwd-reset-color

ptyfwd: reset colors when we exit the pty forwarding logic
This commit is contained in:
Yu Watanabe
2023-12-21 01:17:00 +09:00
committed by GitHub

View 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);
}
@@ -547,6 +552,8 @@ int pty_forward_new(
}
PTYForward *pty_forward_free(PTYForward *f) {
if (!f)
return NULL;
pty_forward_disconnect(f);
return mfree(f);
}