From 1f07fc01de2e57a92e93861d4e3b7cd39e44fe86 Mon Sep 17 00:00:00 2001 From: Stein Ivar Berghei Date: Thu, 30 Mar 2023 18:38:53 +0200 Subject: [PATCH] Redo mpd.pid handling. Fixes #9 --- mpd.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mpd.go b/mpd.go index b32ff0a..e6a5dc4 100644 --- a/mpd.go +++ b/mpd.go @@ -42,10 +42,7 @@ func init() { f.Close() pidstr, err := os.ReadFile(config.GetString("mpd.pid")) - switch err { - case os.ErrNotExist: - log.Println("Pidfile not found, doing nothing") - case nil: + if err != nil && os.IsNotExist(err) { pid, _ := strconv.Atoi(string(bytes.TrimSpace(pidstr))) proc, err := os.FindProcess(pid) switch err { @@ -56,7 +53,7 @@ func init() { default: log.Fatal(err) } - default: + } else if err != nil { log.Fatal(err) }