@@ -28,10 +28,7 @@ import (
2828)
2929
3030func main () {
31- baseCtx , cancel := context .WithCancel (context .Background ())
32- defer cancel ()
33-
34- ctx , cancelNotify := signal .NotifyContext (baseCtx , platformsignals .TerminationSignals ... )
31+ ctx , cancelNotify := signal .NotifyContext (context .Background (), platformsignals .TerminationSignals ... )
3532 defer cancelNotify ()
3633
3734 dockerCli , err := command .NewDockerCli (command .WithBaseContext (ctx ))
@@ -273,11 +270,8 @@ func tryPluginRun(ctx context.Context, dockerCli command.Cli, cmd *cobra.Command
273270 // or EBADF; but that is fine for our purposes.
274271 _ = srv .Close ()
275272
276- // If we're still running after 3 interruptions
277- // (SIGINT/SIGTERM), send a SIGKILL to the plugin as a
278- // final attempt to terminate, and exit.
273+ // force the process to terminate if it hasn't already
279274 if force {
280- _ , _ = fmt .Fprint (dockerCli .Err (), "got 3 SIGTERM/SIGINTs, forcefully exiting\n " )
281275 _ = plugincmd .Process .Kill ()
282276 os .Exit (1 )
283277 }
@@ -301,6 +295,7 @@ func tryPluginRun(ctx context.Context, dockerCli command.Cli, cmd *cobra.Command
301295 // final attempt to terminate, and exit.
302296 if retries >= exitLimit {
303297 force = true
298+ _ , _ = fmt .Fprint (dockerCli .Err (), "got 3 SIGTERM/SIGINTs, forcefully exiting\n " )
304299 }
305300 tryTerminatePlugin (force )
306301 }
0 commit comments