Also handle SIGPIPE as the Go runtime does funky things with this signal

This commit is contained in:
Kovid Goyal 2022-08-25 10:06:37 +05:30
parent 80c5ac891d
commit 6f8c884bb5
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 17 additions and 1 deletions

View File

@ -174,6 +174,10 @@ func (self *Loop) on_SIGINT() error {
return nil
}
func (self *Loop) on_SIGPIPE() error {
return nil
}
func (self *Loop) on_SIGWINCH() error {
self.screen_size.updated = false
if self.OnResize != nil {
@ -287,7 +291,7 @@ func (self *Loop) Run() (err error) {
}()
sigchnl := make(chan os.Signal, 256)
reset_signals := notify_signals(sigchnl, SIGINT, SIGTERM, SIGTSTP, SIGHUP, SIGWINCH)
reset_signals := notify_signals(sigchnl, SIGINT, SIGTERM, SIGTSTP, SIGHUP, SIGWINCH, SIGPIPE)
defer reset_signals()
go func() {

View File

@ -23,6 +23,7 @@ const (
SIGUSR2 Signal = 8
SIGALRM Signal = 9
SIGWINCH Signal = 10
SIGPIPE Signal = 11
)
func (self *Signal) String() string {
@ -49,6 +50,8 @@ func (self *Signal) String() string {
return "SIGALRM"
case SIGWINCH:
return "SIGWINCH"
case SIGPIPE:
return "SIGPIPE"
default:
return fmt.Sprintf("SIG#%d", *self)
}
@ -76,6 +79,8 @@ func as_signal(which os.Signal) Signal {
return SIGALRM
case unix.SIGWINCH:
return SIGWINCH
case unix.SIGPIPE:
return SIGPIPE
default:
return SIGNULL
}
@ -105,6 +110,8 @@ func as_go_signal(which Signal) os.Signal {
return unix.SIGALRM
case SIGWINCH:
return unix.SIGWINCH
case SIGPIPE:
return unix.SIGPIPE
default:
return zero_go_signal
}
@ -160,6 +167,11 @@ func (self *Loop) read_signals(f *os.File, buf []byte) error {
if err != nil {
return err
}
case SIGPIPE:
err := self.on_SIGPIPE()
if err != nil {
return err
}
case SIGTSTP:
err := self.on_SIGTSTP()
if err != nil {