aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlawl <github@dumbinter.net>2020-07-19 12:08:25 +0200
committerlawl <github@dumbinter.net>2020-07-19 12:08:25 +0200
commit23e32356c6ca5e1cbd8b2464706908c41c2db46b (patch)
tree0f112776f852cfefefb6d294eb78afb578be3e4c
parent93fe38ec41037aa869d8c752ec96b7b7776e184b (diff)
downloadnoisetorch-23e32356c6ca5e1cbd8b2464706908c41c2db46b.tar.gz
noisetorch-23e32356c6ca5e1cbd8b2464706908c41c2db46b.zip
Use fallback if RUNTIME_DIR not set
-rw-r--r--rlimit.go4
1 files 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