Give the kill signal time to be delivered

This commit is contained in:
Kovid Goyal
2022-08-25 13:47:22 +05:30
parent a939bbb3ec
commit fa4711bd04

View File

@@ -273,14 +273,20 @@ func (self *Loop) ScreenSize() (ScreenSize, error) {
return self.screen_size, err return self.screen_size, err
} }
func kill_self(sig unix.Signal) {
unix.Kill(os.Getpid(), sig)
// Give the signal time to be delivered
time.Sleep(20 * time.Millisecond)
}
func (self *Loop) KillIfSignalled() { func (self *Loop) KillIfSignalled() {
switch self.death_signal { switch self.death_signal {
case SIGINT: case SIGINT:
unix.Kill(os.Getpid(), unix.SIGINT) kill_self(unix.SIGINT)
case SIGTERM: case SIGTERM:
unix.Kill(os.Getpid(), unix.SIGTERM) kill_self(unix.SIGTERM)
case SIGHUP: case SIGHUP:
unix.Kill(os.Getpid(), unix.SIGHUP) kill_self(unix.SIGHUP)
} }
} }