From 23e32356c6ca5e1cbd8b2464706908c41c2db46b Mon Sep 17 00:00:00 2001 From: lawl Date: Sun, 19 Jul 2020 12:08:25 +0200 Subject: [PATCH] Use fallback if RUNTIME_DIR not set --- rlimit.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rlimit.go b/rlimit.go index 1355965..bb76c5e 100644 --- a/rlimit.go +++ b/rlimit.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "io/ioutil" "log" "os" @@ -15,8 +16,7 @@ import ( const rlimitRTTime = 15 func getPulsePid() (int, error) { - runtimeDir := os.Getenv("XDG_RUNTIME_DIR") - pulsepidfile := filepath.Join(runtimeDir, "pulse/pid") + pulsepidfile := filepath.Join(xdgOrFallback("XDG_RUNTIME_DIR", fmt.Sprintf("/run/user/%d", os.Getuid())), "pulse/pid") pidbuf, err := ioutil.ReadFile(pulsepidfile) if err != nil { return 0, err