Skip to content

Commit

Permalink
Improve pidfile location for non-root
Browse files Browse the repository at this point in the history
Improve pidfile location for non-root users. Use XDG_RUNTIME_PATH if
set.
  • Loading branch information
tempusfrangit committed Mar 14, 2024
1 parent d706d1e commit 87835a6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cmd/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ func defaultPidFilePath() string {
// If we're on OS X, use the user's home directory
// Otherwise, use /run
path := "/run/pget.pid"
if runtime.GOOS == "darwin" {
if xdgPath, ok := os.LookupEnv("XDG_RUNTIME_DIR"); ok {
path = xdgPath + "/pget.pid"
} else if runtime.GOOS == "darwin" {
path = os.Getenv("HOME") + "/.pget.pid"
}
return path
Expand Down

0 comments on commit 87835a6

Please sign in to comment.