Skip to content

Commit

Permalink
Fix: single fifo avoid bidirectional read and writ
Browse files Browse the repository at this point in the history
  • Loading branch information
zijiren233 committed Mar 11, 2024
1 parent 16e7a60 commit 659dccc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions cmd/start/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package start

import (
"fmt"
"io"
"os"
"syscall"
"time"
Expand Down Expand Up @@ -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)
}
}
Expand All @@ -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)
}
5 changes: 3 additions & 2 deletions cmd/start/control_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package start

import (
"fmt"
"io"
"time"

pty "github.com/MCSManager/pty/console"
Expand Down Expand Up @@ -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)
}()
}
Expand All @@ -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)
}

0 comments on commit 659dccc

Please sign in to comment.