From fc7f7dffa869ad1a4a3f097a302282e1b7de8996 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Thu, 5 Nov 2015 13:29:37 -0700 Subject: [PATCH] Prevent panic in case of hung loading sequence (fixes #315) This is known to happen if another program spawns Caddy with a stdin pipe but does not close its write end of Caddy's stdin. --- caddy/sigtrap_posix.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/caddy/sigtrap_posix.go b/caddy/sigtrap_posix.go index 521866fd1..9a9195506 100644 --- a/caddy/sigtrap_posix.go +++ b/caddy/sigtrap_posix.go @@ -22,6 +22,12 @@ func init() { var updatedCaddyfile Input caddyfileMu.Lock() + if caddyfile == nil { + // Hmm, did spawing process forget to close stdin? Anyhow, this is unusual. + log.Println("[ERROR] SIGUSR1: no caddyfile to reload") + caddyfileMu.Unlock() + continue + } if caddyfile.IsFile() { body, err := ioutil.ReadFile(caddyfile.Path()) if err == nil {