Browse Source

Merge pull request #74 from tendermint/73-undefined-syscall-kill

use os.Process#Kill (Fixes #73)
pull/1842/head
Anton Kaliaev 7 years ago
committed by GitHub
parent
commit
ac0cf0b2e2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions
  1. +8
    -3
      common/os.go

+ 8
- 3
common/os.go View File

@ -35,6 +35,8 @@ func GoPath() string {
return path
}
// TrapSignal catches the SIGTERM and executes cb function. After that it exits
// with code 1.
func TrapSignal(cb func()) {
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
@ -50,10 +52,13 @@ func TrapSignal(cb func()) {
select {}
}
// Kill the running process by sending itself SIGTERM
// Kill the running process by sending itself SIGTERM.
func Kill() error {
pid := os.Getpid()
return syscall.Kill(pid, syscall.SIGTERM)
p, err := os.FindProcess(os.Getpid())
if err != nil {
return err
}
return p.Signal(syscall.SIGTERM)
}
func Exit(s string) {


Loading…
Cancel
Save