fix: handle job being nil (first sh exec case)

pull/128/head
TorchedSammy 2022-03-21 21:25:43 -04:00
parent f27d60f827
commit 1e884e7c89
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 8 additions and 5 deletions

13
exec.go
View File

@ -261,11 +261,14 @@ func execCommand(cmd string) error {
} }
err = cmd.Start() err = cmd.Start()
job := jobs.getLatest() var j *job
job.setHandle(cmd.Process) if bg {
j = jobs.getLatest()
j.setHandle(cmd.Process)
}
if err == nil { if err == nil {
if bg { if bg {
job.start(cmd.Process.Pid) j.start(cmd.Process.Pid)
} }
if done := ctx.Done(); done != nil { if done := ctx.Done(); done != nil {
@ -321,8 +324,8 @@ func execCommand(cmd string) error {
} }
end: end:
if bg { if bg {
job.exitCode = int(exit) j.exitCode = int(exit)
job.finish() j.finish()
} }
return interp.NewExitStatus(exit) return interp.NewExitStatus(exit)
} }