Permalink
Browse files

Use XDG_RUNTIME_DIR to guess the best location for the PID file

  • Loading branch information...
1 parent 185d2db commit e3fef5b432ec4bee238abfbd8e06bbedc9b90433 @etix committed Jul 25, 2017
Showing with 5 additions and 1 deletion.
  1. +5 −1 process/process.go
View
@@ -121,7 +121,11 @@ func KillParent(ppid int) error {
func GetPidLocation() string {
if core.PidFile == "" { // Runtime
if defaultPidFile == "" { // Compile time
- return "/var/run/mirrorbits.pid" // Fallback
+ rdir := os.Getenv("XDG_RUNTIME_DIR")
+ if rdir == "" {
+ return "/var/run/mirrorbits.pid" // Fallback
+ }
+ return rdir + "/mirrorbits.pid"
}
return defaultPidFile
}

0 comments on commit e3fef5b

Please sign in to comment.