]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ptyfwd: turn off O_NONBLOCK on output after soft reset
authorMike Yuan <me@yhndnzj.com>
Mon, 22 Dec 2025 16:35:33 +0000 (17:35 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 24 Dec 2025 07:07:59 +0000 (08:07 +0100)
Follow-up for 3d97db8f3c3e86b70d09444965ebfddd051df39c

terminal_reset_ansi_req() would try to put terminal in nonblocking
mode temporarily again, hence just avoid the back and forth
and reset nonblocking as last step.

src/shared/ptyfwd.c

index b3b2acd0fb3cc6727d112267dca6055775e565f4..2e8d77dee1c4325ce63aa2fc1ed9968b545f137a 100644 (file)
@@ -131,9 +131,6 @@ static void pty_forward_disconnect(PTYForward *f) {
                 if (f->saved_stdout)
                         (void) tcsetattr(f->output_fd, TCSANOW, &f->saved_stdout_attr);
 
-                /* STDIN/STDOUT should not be non-blocking normally, so let's reset it */
-                (void) fd_nonblock(f->output_fd, false);
-
                 if (f->last_char_set && f->last_char != '\n') {
                         const char *s;
 
@@ -154,6 +151,9 @@ static void pty_forward_disconnect(PTYForward *f) {
                         terminal_reset_ansi_seq(f->output_fd);
                 }
 
+                /* STDIN/STDOUT should not be non-blocking normally, so let's reset it */
+                (void) fd_nonblock(f->output_fd, false);
+
                 if (f->close_output_fd)
                         f->output_fd = safe_close(f->output_fd);
         }