Redo mpd.pid handling. Fixes #9

pull/11/head
Stein Ivar Berghei 2023-03-30 18:38:53 +02:00
parent 33230a54d5
commit 1f07fc01de
1 changed files with 2 additions and 5 deletions

7
mpd.go
View File

@ -42,10 +42,7 @@ func init() {
f.Close() f.Close()
pidstr, err := os.ReadFile(config.GetString("mpd.pid")) pidstr, err := os.ReadFile(config.GetString("mpd.pid"))
switch err { if err != nil && os.IsNotExist(err) {
case os.ErrNotExist:
log.Println("Pidfile not found, doing nothing")
case nil:
pid, _ := strconv.Atoi(string(bytes.TrimSpace(pidstr))) pid, _ := strconv.Atoi(string(bytes.TrimSpace(pidstr)))
proc, err := os.FindProcess(pid) proc, err := os.FindProcess(pid)
switch err { switch err {
@ -56,7 +53,7 @@ func init() {
default: default:
log.Fatal(err) log.Fatal(err)
} }
default: } else if err != nil {
log.Fatal(err) log.Fatal(err)
} }