mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-29 14:11:21 +00:00
Merge pull request #74 from tendermint/73-undefined-syscall-kill
use os.Process#Kill (Fixes #73)
This commit is contained in:
commit
ac0cf0b2e2
11
common/os.go
11
common/os.go
@ -35,6 +35,8 @@ func GoPath() string {
|
|||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TrapSignal catches the SIGTERM and executes cb function. After that it exits
|
||||||
|
// with code 1.
|
||||||
func TrapSignal(cb func()) {
|
func TrapSignal(cb func()) {
|
||||||
c := make(chan os.Signal, 1)
|
c := make(chan os.Signal, 1)
|
||||||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||||
@ -50,10 +52,13 @@ func TrapSignal(cb func()) {
|
|||||||
select {}
|
select {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kill the running process by sending itself SIGTERM
|
// Kill the running process by sending itself SIGTERM.
|
||||||
func Kill() error {
|
func Kill() error {
|
||||||
pid := os.Getpid()
|
p, err := os.FindProcess(os.Getpid())
|
||||||
return syscall.Kill(pid, syscall.SIGTERM)
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return p.Signal(syscall.SIGTERM)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Exit(s string) {
|
func Exit(s string) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user