@@ -223,9 +223,10 @@ func tryPluginRun(dockerCli command.Cli, cmd *cobra.Command, subcommand string,
223223
224224 // Establish the plugin socket, adding it to the environment under a well-known key if successful.
225225 var conn * net.UnixConn
226- socketenv , err := socket .SetupConn (& conn )
226+ listener , err := socket .SetupConn (& conn )
227227 if err == nil {
228- envs = append (envs , socketenv )
228+ envs = append (envs , socket .EnvKey + "=" + listener .Addr ().String ())
229+ defer listener .Close ()
229230 }
230231
231232 plugincmd .Env = append (envs , plugincmd .Env ... )
@@ -240,16 +241,17 @@ func tryPluginRun(dockerCli command.Cli, cmd *cobra.Command, subcommand string,
240241 // we send a SIGKILL to the plugin process and exit
241242 go func () {
242243 retries := 0
243- for s := range signals {
244+ for range signals {
245+ if dockerCli .Out ().IsTerminal () {
246+ // running attached to a terminal, so the plugin will already
247+ // receive signals due to sharing a pgid with the parent CLI
248+ continue
249+ }
244250 if conn != nil {
245251 if err := conn .Close (); err != nil {
246252 _ , _ = fmt .Fprintf (dockerCli .Err (), "failed to signal plugin to close: %v\n " , err )
247253 }
248254 conn = nil
249- } else {
250- // When the plugin is communicating via socket with the host CLI, we perform job control via the socket.
251- // However, if the plugin is an old version that is not socket-aware, we need to explicitly forward termination signals.
252- plugincmd .Process .Signal (s )
253255 }
254256 retries ++
255257 if retries >= exitLimit {
0 commit comments