in pkg/api/internal/jobs/jobs.go [160:182]
func (j *Job) Close() {
j.closeOnce.Do(func() {
j.cancel()
// block until Run has exited
select {
case <-j.finishC:
case <-time.NewTimer(j.runExitWaitTime).C:
// A caller called close without first calling Run... 2 seconds ought to be enough for exec.Cmd.Run() to
// return...
j.mux.Lock()
defer j.mux.Unlock()
if j.status == proto.StepResult_unspecified {
j.status = proto.StepResult_cancelled
}
if j.err == nil {
j.err = context.Canceled
}
}
_ = os.RemoveAll(j.TmpDir)
})
}