From c3a6de9ec80d03aa0b0a7493d787eb706d2e2b11 Mon Sep 17 00:00:00 2001 From: Cory Snider Date: Wed, 28 Sep 2022 11:46:59 -0400 Subject: [PATCH] logger/journald: unlock OS threads Managed containerd processes are executed with SysProcAttr.Pdeathsig set to syscall.SIGKILL so that the managed containerd is automatically killed along with the daemon. At least, that is the intention. In practice, the signal is sent to the process when the creating _OS thread_ dies! If a goroutine exits while locked to an OS thread, the Go runtime will terminate the thread. If that thread happens to be the same thread which the subprocess was started from, the subprocess will be signaled. Prevent the journald driver from sometimes unintentionally killing child processes by ensuring that all runtime.LockOSThread() calls are paired with runtime.UnlockOSThread(). Signed-off-by: Cory Snider --- daemon/logger/journald/read.go | 1 + 1 file changed, 1 insertion(+) diff --git a/daemon/logger/journald/read.go b/daemon/logger/journald/read.go index 451a21b139..8c2b7db26a 100644 --- a/daemon/logger/journald/read.go +++ b/daemon/logger/journald/read.go @@ -404,6 +404,7 @@ func waitUntilFlushedImpl(s *journald) error { go func() { defer close(flushed) runtime.LockOSThread() + defer runtime.UnlockOSThread() var ( j *sdjournal.Journal