Skip to content

Commit a790ddf

Browse files
committed
proc/debuginfod: add timeouts to debuginfod-find
Calls to debuginfod-find can take an arbitrarily long time to complete. Set timeouts for them unless they were explicitly set by user, also redirect its stderr to our stderr so that, if they produce progress output, it is seen. Updates #3906
1 parent 28eab0c commit a790ddf

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pkg/proc/debuginfod/debuginfod.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
package debuginfod
22

33
import (
4+
"os"
45
"os/exec"
56
"strings"
67
)
78

8-
const debuginfodFind = "debuginfod-find"
9+
const (
10+
debuginfodFind = "debuginfod-find"
11+
debuginfodMaxtimeEnv = "DEBUGINFOD_MAXTIME"
12+
debuginfodTimeoutEnv = "DEBUGINFOD_TIMEOUT"
13+
)
914

1015
func execFind(args ...string) (string, error) {
1116
if _, err := exec.LookPath(debuginfodFind); err != nil {
1217
return "", err
1318
}
1419
cmd := exec.Command(debuginfodFind, args...)
20+
if os.Getenv(debuginfodMaxtimeEnv) == "" || os.Getenv(debuginfodTimeoutEnv) == "" {
21+
cmd.Env = append(os.Environ(), debuginfodMaxtimeEnv+"=1", debuginfodTimeoutEnv+"=1")
22+
}
23+
cmd.Stderr = os.Stderr
1524
out, err := cmd.Output() // ignore stderr
1625
if err != nil {
1726
return "", err

0 commit comments

Comments
 (0)