github.com/qioalice/ekago/v3@v3.3.2-0.20221202205325-5c262d586ee4/ekadeath/init.go (about) 1 // Copyright © 2019-2021. All rights reserved. 2 // Author: Ilya Stroy. 3 // Contacts: iyuryevich@pm.me, https://github.com/qioalice 4 // License: https://opensource.org/licenses/MIT 5 6 package ekadeath 7 8 import ( 9 "os" 10 "os/signal" 11 "syscall" 12 ) 13 14 // Spawns goroutine which can handle SIGKILL, SIGTERM that leads to call Die(1). 15 func init() { 16 ch := make(chan os.Signal) 17 signal.Notify(ch, os.Interrupt, syscall.SIGKILL, syscall.SIGTERM) 18 go func() { 19 _ = <-ch // blocks 20 Die(1) 21 }() 22 }