From 5f6c55a72449177e8f370f70c7009ed53ebd0ed7 Mon Sep 17 00:00:00 2001 From: Laura Brehm Date: Mon, 15 Jan 2024 13:16:53 +0000 Subject: [PATCH] plugins: don't handle signal/notify if TTY In order to solve the "double notification" issue (see: https://github.com/docker/cli/commit/ef5e5fa03f0603f48678bfd7039c5b8121d98df1) without running the plugin process under a new pgid (see: https://github.com/moby/moby/issues/47073) we instead check if we're attached to a TTY, and if so skip signalling the plugin process since it will already be signalled. Signed-off-by: Laura Brehm --- cmd/docker/docker.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/docker/docker.go b/cmd/docker/docker.go index 2b1b951a50..f3bc230080 100644 --- a/cmd/docker/docker.go +++ b/cmd/docker/docker.go @@ -241,6 +241,11 @@ func tryPluginRun(dockerCli command.Cli, cmd *cobra.Command, subcommand string, go func() { retries := 0 for range signals { + if dockerCli.Out().IsTerminal() { + // running attached to a terminal, so the plugin will already + // receive signals due to sharing a pgid with the parent CLI + continue + } if conn != nil { if err := conn.Close(); err != nil { _, _ = fmt.Fprintf(dockerCli.Err(), "failed to signal plugin to close: %v\n", err)