mirror of
https://github.com/junegunn/fzf
synced 2026-07-28 17:51:42 +00:00
dc384afb70
- Pass Loop context to notifyOnResize - Windows: stop polling goroutine, close CONOUT$ handle on ctx.Done - Unix: unregister SIGWINCH handler on ctx.Done
30 lines
444 B
Go
30 lines
444 B
Go
//go:build !windows
|
|
|
|
package fzf
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
func notifyOnResize(ctx context.Context, resizeChan chan<- os.Signal) {
|
|
signal.Notify(resizeChan, syscall.SIGWINCH)
|
|
go func() {
|
|
<-ctx.Done()
|
|
signal.Stop(resizeChan)
|
|
}()
|
|
}
|
|
|
|
func notifyStop(p *os.Process) {
|
|
pid := p.Pid
|
|
pgid, err := unix.Getpgid(pid)
|
|
if err == nil {
|
|
pid = pgid * -1
|
|
}
|
|
unix.Kill(pid, syscall.SIGTSTP)
|
|
}
|