From 919e5b5cd5deb16087f4a85e2801e73643d7dce4 Mon Sep 17 00:00:00 2001 From: Ophestra Umiker Date: Thu, 17 Oct 2024 20:46:25 +0900 Subject: [PATCH] init: start timeout only if reaped PID is the initial process Fix a very obvious bug introduced in 5401882ed0. Signed-off-by: Ophestra Umiker --- internal/init/main.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/init/main.go b/internal/init/main.go index e79618b..b70aebc 100644 --- a/internal/init/main.go +++ b/internal/init/main.go @@ -145,11 +145,12 @@ func doInit(fd uintptr) { default: r = 255 } + + go func() { + time.Sleep(residualProcessTimeout) + close(timeout) + }() } - go func() { - time.Sleep(residualProcessTimeout) - close(timeout) - }() case <-done: os.Exit(r) case <-timeout: