Sending SIGINT to app so app can invoke any registered signal handlers#3
Sending SIGINT to app so app can invoke any registered signal handlers#3jaijiv wants to merge 2 commits intomarkbates:masterfrom
Conversation
| pid := cmd.Process.Pid | ||
| m.Logger.Success("Stopping: PID %d", pid) | ||
| cmd.Process.Kill() | ||
| if err := cmd.Process.Signal(syscall.SIGINT); err != nil { |
There was a problem hiding this comment.
Is this going to work on Windows? From the docs:
func (*Process) Signal: Signal sends a signal to the Process. Sending Interrupt on Windows is not implemented.
There was a problem hiding this comment.
On windows, it should return an error. On error, this defaults to Process.Kill(). Unfortunately i do not have a windows box to test.
from exec_windows.go
func (p *Process) signal(sig Signal) error {
handle := atomic.LoadUintptr(&p.handle)
if handle == uintptr(syscall.InvalidHandle) {
return syscall.EINVAL
}
if p.done() {
return errors.New("os: process already finished")
}
if sig == Kill {
return terminateProcess(p.Pid, 1)
}
// TODO(rsc): Handle Interrupt too?
return syscall.Errno(syscall.EWINDOWS)
}
There was a problem hiding this comment.
@bketelsen do you still have a windows box? If so, could you try this PR on it to make sure it works?
This PR is to make refresh send a SIGINT to app instead of KILL so any app signal handlers can be invoked