Skip to content

Commit

Permalink
attempt to interupt process before killing
Browse files Browse the repository at this point in the history
  • Loading branch information
Gareth Jones authored and Gareth Jones committed Jul 8, 2013
1 parent 3268ba6 commit 02bb5cd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions libwebsocketd/process_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package libwebsocketd
import (
"bufio"
"io"
"syscall"
)

type ProcessEndpoint struct {
Expand All @@ -28,9 +29,13 @@ func NewProcessEndpoint(process *LaunchedProcess, log *LogScope) *ProcessEndpoin
func (pe *ProcessEndpoint) Terminate() {
pe.process.stdin.Close()

err := pe.process.cmd.Process.Kill()
err := pe.process.cmd.Process.Signal(syscall.SIGINT)
if err != nil {
pe.log.Debug("process", "Failed to kill process %v: %s", pe.process.cmd.Process.Pid, err)
pe.log.Debug("process", "Failed to Interupt process %v: %s, attempting to kill", pe.process.cmd.Process.Pid, err)
err = pe.process.cmd.Process.Kill()
if err != nil {
pe.log.Debug("process", "Failed to Kill process %v: %s", pe.process.cmd.Process.Pid, err)
}
}

pe.process.cmd.Wait()
Expand Down

0 comments on commit 02bb5cd

Please sign in to comment.