MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / KillGraceful

Method KillGraceful

pkg/shellexec/conninterface.go:86–111  ·  view source on GitHub ↗
(timeout time.Duration)

Source from the content-addressed store, hash-verified

84}
85
86func (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
113func (cw CmdWrap) Start() error {
114 defer func() {

Callers

nothing calls this directly

Calls 4

SignalHupFunction · 0.92
SignalTermFunction · 0.92
PanicHandlerFunction · 0.92
KillMethod · 0.65

Tested by

no test coverage detected