We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 50c6508 commit 3749aaaCopy full SHA for 3749aaa
cmd/godotenv/cmd.go
@@ -1,6 +1,7 @@
1
package main
2
3
import (
4
+ "context"
5
"flag"
6
"fmt"
7
"log"
@@ -54,12 +55,16 @@ example
54
55
cmd := args[0]
56
cmdArgs := args[1:]
57
- command := exec.Command(cmd, cmdArgs...)
58
+ ctx, cancel := context.WithCancel(context.Background())
59
+ notify := make(chan os.Signal, 1)
60
+ signal.Notify(notify, os.Interrupt)
61
+ go func() { <-notify; cancel() }()
62
+
63
+ command := exec.CommandContext(ctx, cmd, cmdArgs...)
64
command.Stdin = os.Stdin
65
command.Stdout = os.Stdout
66
command.Stderr = os.Stderr
67
- signal.Ignore(os.Interrupt)
68
if err := command.Run(); err != nil {
69
log.Fatal(err)
70
}
0 commit comments