@@ -18,6 +18,7 @@ import (
1818 "github.com/gruntwork-io/terragrunt/config"
1919 "github.com/gruntwork-io/terragrunt/internal/component"
2020 "github.com/gruntwork-io/terragrunt/internal/filter"
21+ "github.com/gruntwork-io/terragrunt/internal/os/signal"
2122 "github.com/gruntwork-io/terragrunt/pkg/log"
2223 "github.com/gruntwork-io/terragrunt/pkg/log/writer"
2324 "golang.org/x/exp/slices"
@@ -289,7 +290,33 @@ func bytesDiff(ctx context.Context, l log.Logger, b1, b2 []byte, path string) ([
289290 return nil , err
290291 }
291292
292- data , err := exec .CommandContext (ctx , "diff" , "--label=" + filepath .Join ("old" , path ), "--label=" + filepath .Join ("new/" , path ), "-u" , f1 .Name (), f2 .Name ()).CombinedOutput ()
293+ diffPath , err := exec .LookPath ("diff" )
294+ if err != nil {
295+ return nil , fmt .Errorf ("failed to find diff command in PATH: %w" , err )
296+ }
297+
298+ cmd := exec .CommandContext (
299+ ctx ,
300+ diffPath ,
301+ "--label=" + filepath .Join ("old" , path ),
302+ "--label=" + filepath .Join ("new/" , path ),
303+ "-u" ,
304+ f1 .Name (),
305+ f2 .Name (),
306+ )
307+ cmd .Cancel = func () error {
308+ if cmd .Process == nil {
309+ return nil
310+ }
311+
312+ if sig := signal .SignalFromContext (ctx ); sig != nil {
313+ return cmd .Process .Signal (sig )
314+ }
315+
316+ return cmd .Process .Signal (os .Kill )
317+ }
318+
319+ data , err := cmd .CombinedOutput ()
293320 if len (data ) > 0 {
294321 // diff exits with a non-zero status when the files don't match.
295322 // Ignore that failure as long as we get output.
0 commit comments