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
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -273,14 +273,20 @@ func (self *Loop) ScreenSize() (ScreenSize, error) {
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() {
switch self.death_signal {
case SIGINT:
unix.Kill(os.Getpid(), unix.SIGINT)
kill_self(unix.SIGINT)
case SIGTERM:
unix.Kill(os.Getpid(), unix.SIGTERM)
kill_self(unix.SIGTERM)
case SIGHUP:
unix.Kill(os.Getpid(), unix.SIGHUP)
kill_self(unix.SIGHUP)
}
}