chore: publish pxmon v0.2.0
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
//go:build !windows
|
||||
|
||||
package cli
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/term"
|
||||
|
||||
"pxmon/internal/cluster"
|
||||
)
|
||||
|
||||
func installWinchHandler(fd int, resize chan<- cluster.InteractiveShellSize) chan os.Signal {
|
||||
sigCh := make(chan os.Signal, 4)
|
||||
signal.Notify(sigCh, syscall.SIGWINCH)
|
||||
go func() {
|
||||
for range sigCh {
|
||||
w, h, err := term.GetSize(fd)
|
||||
if err != nil || w <= 0 || h <= 0 {
|
||||
continue
|
||||
}
|
||||
select {
|
||||
case resize <- cluster.InteractiveShellSize{Width: w, Height: h}:
|
||||
default:
|
||||
}
|
||||
}
|
||||
}()
|
||||
return sigCh
|
||||
}
|
||||
|
||||
func closeWinchHandler(sigCh chan os.Signal, resize chan cluster.InteractiveShellSize) {
|
||||
if sigCh != nil {
|
||||
signal.Stop(sigCh)
|
||||
close(sigCh)
|
||||
}
|
||||
if resize != nil {
|
||||
close(resize)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user