mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
internal/build: fix goroutine leak in MustRunCommandWithOutput
This commit is contained in:
parent
7124057bad
commit
7d39afed04
1 changed files with 9 additions and 2 deletions
|
|
@ -73,10 +73,17 @@ func MustRunCommand(cmd string, args ...string) {
|
|||
// when there is no output.
|
||||
func MustRunCommandWithOutput(cmd string, args ...string) {
|
||||
interval := time.NewTicker(time.Minute)
|
||||
done := make(chan struct{})
|
||||
defer interval.Stop()
|
||||
defer close(done)
|
||||
go func() {
|
||||
for range interval.C {
|
||||
fmt.Printf("Waiting for command %q\n", cmd)
|
||||
for {
|
||||
select {
|
||||
case <-interval.C:
|
||||
fmt.Printf("Waiting for command %q\n", cmd)
|
||||
case <-done:
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
MustRun(exec.Command(cmd, args...))
|
||||
|
|
|
|||
Loading…
Reference in a new issue