From fbc4768a003e5dc95014e216e675b20b0fdd102f Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Sun, 14 Jul 2024 19:44:43 +0200 Subject: [PATCH] libpod: shutdown Stop waits for handlers completion wait for handlers currently being processed. Signed-off-by: Giuseppe Scrivano --- libpod/shutdown/handler.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libpod/shutdown/handler.go b/libpod/shutdown/handler.go index 2b30a95768..d7fd5b5323 100644 --- a/libpod/shutdown/handler.go +++ b/libpod/shutdown/handler.go @@ -91,6 +91,11 @@ func Stop() error { return nil } + // if the signal handler is running, wait that it terminates + handlerLock.Lock() + defer handlerLock.Unlock() + // it doesn't need to be in the critical section, but staticcheck complains if + // the critical section is empty. cancelChan <- true return nil