From 659dccc8383a087af7ca80a258dd6f11058d1688 Mon Sep 17 00:00:00 2001 From: zijiren233 Date: Mon, 11 Mar 2024 17:54:57 +0800 Subject: [PATCH] Fix: single fifo avoid bidirectional read and writ --- cmd/start/control.go | 5 +++-- cmd/start/control_windows.go | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/start/control.go b/cmd/start/control.go index faebf4d..cddf98e 100644 --- a/cmd/start/control.go +++ b/cmd/start/control.go @@ -5,6 +5,7 @@ package start import ( "fmt" + "io" "os" "syscall" "time" @@ -36,7 +37,7 @@ func runControl(fifo string, con pty.Console) error { return fmt.Errorf("open fifo error: %w", err) } defer f.Close() - u := newConnUtils(f, f) + u := newConnUtils(f, io.Discard) _ = handleConn(u, con) } } @@ -47,6 +48,6 @@ func testUnixResize(fifo string) error { return fmt.Errorf("open fifo error: %w", err) } defer n.Close() - u := newConnUtils(n, n) + u := newConnUtils(nil, n) return testResize(u) } diff --git a/cmd/start/control_windows.go b/cmd/start/control_windows.go index b31f22d..2ac9ae2 100644 --- a/cmd/start/control_windows.go +++ b/cmd/start/control_windows.go @@ -2,6 +2,7 @@ package start import ( "fmt" + "io" "time" pty "github.com/MCSManager/pty/console" @@ -31,7 +32,7 @@ func runControl(fifo string, con pty.Console) error { } go func() { defer conn.Close() - u := newConnUtils(conn, conn) + u := newConnUtils(conn, io.Discard) _ = handleConn(u, con) }() } @@ -42,6 +43,6 @@ func testWinResize(fifo string) error { if err != nil { return fmt.Errorf("open fifo error: %w", err) } - u := newConnUtils(n, n) + u := newConnUtils(nil, n) return testResize(u) }