Fix CTRL-Z handling: Signal SIGSTOP to PGID

Fix #3501
This commit is contained in:
Junegunn Choi 2023-11-04 13:46:29 +09:00
parent 68db9cb499
commit 70c19ccf16
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
1 changed files with 8 additions and 1 deletions

View File

@ -7,6 +7,8 @@ import (
"os/signal"
"strings"
"syscall"
"golang.org/x/sys/unix"
)
func notifyOnResize(resizeChan chan<- os.Signal) {
@ -14,7 +16,12 @@ func notifyOnResize(resizeChan chan<- os.Signal) {
}
func notifyStop(p *os.Process) {
p.Signal(syscall.SIGSTOP)
pid := p.Pid
pgid, err := unix.Getpgid(pid)
if err == nil {
pid = pgid * -1
}
unix.Kill(pid, syscall.SIGSTOP)
}
func notifyOnCont(resizeChan chan<- os.Signal) {