(timeout time.Duration)
| 84 | } |
| 85 | |
| 86 | func (cw CmdWrap) KillGraceful(timeout time.Duration) { |
| 87 | if cw.Cmd.Process == nil { |
| 88 | return |
| 89 | } |
| 90 | if cw.Cmd.ProcessState != nil && cw.Cmd.ProcessState.Exited() { |
| 91 | return |
| 92 | } |
| 93 | if runtime.GOOS == "windows" { |
| 94 | cw.Cmd.Process.Kill() |
| 95 | return |
| 96 | } |
| 97 | if cw.IsShell { |
| 98 | unixutil.SignalHup(cw.Cmd.Process.Pid) |
| 99 | } else { |
| 100 | unixutil.SignalTerm(cw.Cmd.Process.Pid) |
| 101 | } |
| 102 | go func() { |
| 103 | defer func() { |
| 104 | panichandler.PanicHandler("KillGraceful:Kill", recover()) |
| 105 | }() |
| 106 | time.Sleep(timeout) |
| 107 | if cw.Cmd.ProcessState == nil || !cw.Cmd.ProcessState.Exited() { |
| 108 | cw.Cmd.Process.Kill() // force kill if it is already not exited |
| 109 | } |
| 110 | }() |
| 111 | } |
| 112 | |
| 113 | func (cw CmdWrap) Start() error { |
| 114 | defer func() { |
nothing calls this directly
no test coverage detected