From 0bd118807b384cd5c2de2562913ee545af758235 Mon Sep 17 00:00:00 2001 From: Ingo Oppermann Date: Mon, 15 Jan 2024 10:42:08 +0100 Subject: [PATCH] Fix race condition --- process/process.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/process/process.go b/process/process.go index 095f9d5d..31723dd0 100644 --- a/process/process.go +++ b/process/process.go @@ -589,7 +589,9 @@ func (p *process) stop(wait bool) error { p.callbacks.onExit = func() { wg.Done() + p.callbacks.lock.Lock() p.callbacks.onExit = nil + p.callbacks.lock.Unlock() } } else { cb := p.callbacks.onExit @@ -597,7 +599,9 @@ func (p *process) stop(wait bool) error { cb() wg.Done() + p.callbacks.lock.Lock() p.callbacks.onExit = cb + p.callbacks.lock.Unlock() } } p.callbacks.lock.Unlock()