Skip to content

Comments

Sending SIGINT to app so app can invoke any registered signal handlers#3

Open
jaijiv wants to merge 2 commits intomarkbates:masterfrom
jaijiv:killsignal
Open

Sending SIGINT to app so app can invoke any registered signal handlers#3
jaijiv wants to merge 2 commits intomarkbates:masterfrom
jaijiv:killsignal

Conversation

@jaijiv
Copy link

@jaijiv jaijiv commented Jan 23, 2017

This PR is to make refresh send a SIGINT to app instead of KILL so any app signal handlers can be invoked

pid := cmd.Process.Pid
m.Logger.Success("Stopping: PID %d", pid)
cmd.Process.Kill()
if err := cmd.Process.Signal(syscall.SIGINT); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bketelsen do you still have a windows box? If so, could you try this PR on it to make sure it works?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants