@@ -42,7 +42,6 @@ import (
4242 "github.com/spf13/cobra"
4343 "github.com/spf13/pflag"
4444
45- "github.com/docker/cli/cli-plugins/plugin"
4645 "github.com/docker/compose/v2/cmd/formatter"
4746 "github.com/docker/compose/v2/pkg/api"
4847 "github.com/docker/compose/v2/pkg/compose"
@@ -74,20 +73,17 @@ type CobraCommand func(context.Context, *cobra.Command, []string) error
7473// AdaptCmd adapt a CobraCommand func to cobra library
7574func AdaptCmd (fn CobraCommand ) func (cmd * cobra.Command , args []string ) error {
7675 return func (cmd * cobra.Command , args []string ) error {
77- ctx := cmd .Context ()
78- contextString := fmt .Sprintf ("%s" , ctx )
79- if ! strings .Contains (contextString , ".WithCancel" ) || plugin .RunningStandalone () { // need to handle cancel
80- cancellableCtx , cancel := context .WithCancel (cmd .Context ())
81- ctx = cancellableCtx
82- s := make (chan os.Signal , 1 )
83- signal .Notify (s , syscall .SIGTERM , syscall .SIGINT )
84- go func () {
85- <- s
86- cancel ()
87- signal .Stop (s )
88- close (s )
89- }()
90- }
76+ ctx , cancel := context .WithCancel (cmd .Context ())
77+
78+ s := make (chan os.Signal , 1 )
79+ signal .Notify (s , syscall .SIGTERM , syscall .SIGINT )
80+ go func () {
81+ <- s
82+ cancel ()
83+ signal .Stop (s )
84+ close (s )
85+ }()
86+
9187 err := fn (ctx , cmd , args )
9288 var composeErr compose.Error
9389 if api .IsErrCanceled (err ) || errors .Is (ctx .Err (), context .Canceled ) {
0 commit comments