From: Ben Pfaff Date: Wed, 21 Jan 2009 00:33:52 +0000 (-0800) Subject: daemon: Fix bogus error message in read_pidfile() when pidfile is empty. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2aada7074f80d24e5abb22b5d4db6183da36a927;p=openvswitch daemon: Fix bogus error message in read_pidfile() when pidfile is empty. --- 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; }