More work on porting receive kitten

This commit is contained in:
Kovid Goyal
2023-07-23 13:29:28 +05:30
parent 73ee5b32c9
commit 3d5fdad029
3 changed files with 263 additions and 15 deletions

View File

@@ -98,6 +98,12 @@ type Loop struct {
// Called when main loop is woken up
OnWakeup func() error
// Called on SIGINT return true if you wish to handle it yourself
OnSIGINT func() (bool, error)
// Called on SIGTERM return true if you wish to handle it yourself
OnSIGTERM func() (bool, error)
}
func New(options ...func(self *Loop)) (*Loop, error) {

View File

@@ -198,12 +198,22 @@ func (self *Loop) handle_end_of_bracketed_paste() {
func (self *Loop) on_signal(s unix.Signal) error {
switch s {
case unix.SIGINT:
if self.OnSIGINT != nil {
if handled, err := self.OnSIGINT(); handled {
return err
}
}
return self.on_SIGINT()
case unix.SIGPIPE:
return self.on_SIGPIPE()
case unix.SIGWINCH:
return self.on_SIGWINCH()
case unix.SIGTERM:
if self.OnSIGTERM != nil {
if handled, err := self.OnSIGTERM(); handled {
return err
}
}
return self.on_SIGTERM()
case unix.SIGTSTP:
return self.on_SIGTSTP()