Skip to content
This repository was archived by the owner on Jul 15, 2018. It is now read-only.

Commit ac0cf0b

Browse files
authored
Merge pull request #74 from tendermint/73-undefined-syscall-kill
use os.Process#Kill (Fixes #73)
2 parents b658294 + 49d75e2 commit ac0cf0b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

common/os.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ func GoPath() string {
3535
return path
3636
}
3737

38+
// TrapSignal catches the SIGTERM and executes cb function. After that it exits
39+
// with code 1.
3840
func TrapSignal(cb func()) {
3941
c := make(chan os.Signal, 1)
4042
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
@@ -50,10 +52,13 @@ func TrapSignal(cb func()) {
5052
select {}
5153
}
5254

53-
// Kill the running process by sending itself SIGTERM
55+
// Kill the running process by sending itself SIGTERM.
5456
func Kill() error {
55-
pid := os.Getpid()
56-
return syscall.Kill(pid, syscall.SIGTERM)
57+
p, err := os.FindProcess(os.Getpid())
58+
if err != nil {
59+
return err
60+
}
61+
return p.Signal(syscall.SIGTERM)
5762
}
5863

5964
func Exit(s string) {

0 commit comments

Comments
 (0)