mirror of https://github.com/Hilbis/Hilbish
fix: handle job being nil (first sh exec case)
parent
f27d60f827
commit
1e884e7c89
13
exec.go
13
exec.go
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue