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

Method waitForProcess

pkg/jobmanager/jobcmd.go:75–110  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

73}
74
75func (jm *JobCmd) waitForProcess() {
76 if jm.cmd == nil || jm.cmd.Process == nil {
77 return
78 }
79 err := jm.cmd.Wait()
80 jm.lock.Lock()
81 defer jm.lock.Unlock()
82
83 jm.processExited = true
84 jm.exitTs = time.Now().UnixMilli()
85 jm.exitErr = err
86 if err != nil {
87 if exitErr, ok := err.(*exec.ExitError); ok {
88 if status, ok := exitErr.Sys().(syscall.WaitStatus); ok {
89 if status.Signaled() {
90 jm.exitSignal = unixutil.GetSignalName(status.Signal())
91 } else if status.Exited() {
92 code := status.ExitStatus()
93 jm.exitCode = &code
94 } else {
95 log.Printf("Invalid WaitStatus, not exited or signaled: %v", status)
96 }
97 }
98 }
99 } else {
100 code := 0
101 jm.exitCode = &code
102 }
103 exitCodeStr := "nil"
104 if jm.exitCode != nil {
105 exitCodeStr = fmt.Sprintf("%d", *jm.exitCode)
106 }
107 log.Printf("process exited: exitcode=%s, signal=%s, err=%v\n", exitCodeStr, jm.exitSignal, jm.exitErr)
108
109 go WshCmdJobManager.sendJobExited()
110}
111
112func (jm *JobCmd) GetCmd() (*exec.Cmd, pty.Pty) {
113 jm.lock.Lock()

Callers 1

MakeJobCmdFunction · 0.95

Calls 4

GetSignalNameFunction · 0.92
SysMethod · 0.80
sendJobExitedMethod · 0.80
WaitMethod · 0.65

Tested by

no test coverage detected