@@ -223,9 +223,10 @@ func tryPluginRun(dockerCli command.Cli, cmd *cobra.Command, subcommand string,
223
223
224
224
// Establish the plugin socket, adding it to the environment under a well-known key if successful.
225
225
var conn * net.UnixConn
226
- socketenv , err := socket .SetupConn (& conn )
226
+ listener , err := socket .SetupConn (& conn )
227
227
if err == nil {
228
- envs = append (envs , socketenv )
228
+ envs = append (envs , socket .EnvKey + "=" + listener .Addr ().String ())
229
+ defer listener .Close ()
229
230
}
230
231
231
232
plugincmd .Env = append (envs , plugincmd .Env ... )
@@ -240,16 +241,17 @@ func tryPluginRun(dockerCli command.Cli, cmd *cobra.Command, subcommand string,
240
241
// we send a SIGKILL to the plugin process and exit
241
242
go func () {
242
243
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
+ }
244
250
if conn != nil {
245
251
if err := conn .Close (); err != nil {
246
252
_ , _ = fmt .Fprintf (dockerCli .Err (), "failed to signal plugin to close: %v\n " , err )
247
253
}
248
254
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 )
253
255
}
254
256
retries ++
255
257
if retries >= exitLimit {
0 commit comments