@@ -42,7 +42,6 @@ import (
42
42
"github.com/spf13/cobra"
43
43
"github.com/spf13/pflag"
44
44
45
- "github.com/docker/cli/cli-plugins/plugin"
46
45
"github.com/docker/compose/v2/cmd/formatter"
47
46
"github.com/docker/compose/v2/pkg/api"
48
47
"github.com/docker/compose/v2/pkg/compose"
@@ -74,20 +73,17 @@ type CobraCommand func(context.Context, *cobra.Command, []string) error
74
73
// AdaptCmd adapt a CobraCommand func to cobra library
75
74
func AdaptCmd (fn CobraCommand ) func (cmd * cobra.Command , args []string ) error {
76
75
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
+
91
87
err := fn (ctx , cmd , args )
92
88
var composeErr compose.Error
93
89
if api .IsErrCanceled (err ) || errors .Is (ctx .Err (), context .Canceled ) {
0 commit comments