mirror of https://github.com/hashicorp/consul
Browse Source
Add a per GOOS implementation to send signals to PIDs since syscall.Kill does not exist on Windows. It will always send a SIGKILL on Windows since there seems to be no POSIX compatible notion. Fixes build on Windows.pull/637/head
Emil Hessman
10 years ago
3 changed files with 43 additions and 8 deletions
@ -0,0 +1,12 @@
|
||||
// +build !windows
|
||||
|
||||
package command |
||||
|
||||
import ( |
||||
"syscall" |
||||
) |
||||
|
||||
// signalPid sends a sig signal to the process with process id pid.
|
||||
func signalPid(pid int, sig syscall.Signal) error { |
||||
return syscall.Kill(pid, sig) |
||||
} |
@ -0,0 +1,19 @@
|
||||
// +build windows
|
||||
|
||||
package command |
||||
|
||||
import ( |
||||
"os" |
||||
"syscall" |
||||
) |
||||
|
||||
// signalPid sends a sig signal to the process with process id pid.
|
||||
// Interrupts et al is not implemented on Windows. Always send a SIGKILL.
|
||||
func signalPid(pid int, sig syscall.Signal) error { |
||||
p, err := os.FindProcess(pid) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
_ = sig |
||||
return p.Signal(syscall.SIGKILL) |
||||
} |
Loading…
Reference in new issue