From 2aada7074f80d24e5abb22b5d4db6183da36a927 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Tue, 20 Jan 2009 16:33:52 -0800 Subject: [PATCH] daemon: Fix bogus error message in read_pidfile() when pidfile is empty. --- lib/daemon.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/daemon.c b/lib/daemon.c index a3b824e6..38cbc7b2 100644 --- a/lib/daemon.c +++ b/lib/daemon.c @@ -278,8 +278,13 @@ read_pidfile(const char *pidfile) } if (!fgets(line, sizeof line, file)) { - error = errno; - VLOG_WARN("%s: read: %s", pidfile, strerror(error)); + if (ferror(file)) { + error = errno; + VLOG_WARN("%s: read: %s", pidfile, strerror(error)); + } else { + error = ESRCH; + VLOG_WARN("%s: read: unexpected end of file", pidfile); + } goto error; } -- 2.30.2