From 1cf3391161fdb05d797af85472e334f2f3a57476 Mon Sep 17 00:00:00 2001 From: Luca Berneking Date: Tue, 12 Mar 2024 16:57:39 +0100 Subject: [PATCH] Fix deadlock on listener job + fix race `startOnce()` msut return an error or write an process into the process channel --- pkg/proc/basejob.go | 2 +- pkg/proc/job_lazy.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/proc/basejob.go b/pkg/proc/basejob.go index 36a275d..3c78104 100644 --- a/pkg/proc/basejob.go +++ b/pkg/proc/basejob.go @@ -108,7 +108,7 @@ func (job *baseJob) startOnce(ctx context.Context, process chan<- *os.Process) e defer job.closeStdFiles() if err := job.CreateAndOpenStdFile(job.Config); err != nil { - return nil + return err } cmd := exec.Command(job.Config.Command, job.Config.Args...) diff --git a/pkg/proc/job_lazy.go b/pkg/proc/job_lazy.go index f0ac7b2..315e99c 100644 --- a/pkg/proc/job_lazy.go +++ b/pkg/proc/job_lazy.go @@ -42,6 +42,8 @@ func (job *LazyJob) AssertStarted(ctx context.Context) error { l.Info("process terminated") + job.lazyStartLock.Lock() + defer job.lazyStartLock.Unlock() job.process = nil }()