[rrd-developers] [PATCH] Re: [PATCH] create the pid file before forking, so we can complain to stderr

kevin brintnall kbrint at rufus.net
Fri Sep 26 15:25:00 CEST 2008

On Fri, Sep 26, 2008 at 10:43:43AM +0200, Sebastian Harl wrote:
> Hi Kevin,
> On Fri, Sep 26, 2008 at 02:23:53AM +0000, kevin brintnall wrote:
> > -    RRDD_LOG (LOG_ERR, "write_pidfile: Opening `%s' failed.", file);
> > +    RRDD_LOG (LOG_ERR, "write_pidfile: fopen() failed.");
> Any reason why you've changed that to a less informative message? If you
> want consistency with the other error messages I'd rather change the
> others to be more verbose about what went wrong.


The PID file is created with open() in the parent process, while we still
have STDERR open.  If it cannot be created, it complains verbosely to

The PID file is written in the child process.  The only way the fdopen()
will fail on a fd that is already open is if you're completely out of
memory.  As in other places in the code, I didn't consider this a case
that required a very verbose message.  (Search for "strdup failed").  If
you still think a more verbose message is called for, please suggest one.

The attached patch corrects the error message to complain about fdopen()
vs fopen().  I hadn't noticed that until you brought it up.

 kevin brintnall =~ /kbrint at rufus.net/


diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c
index d30893e..18b7143 100644
--- a/src/rrd_daemon.c
+++ b/src/rrd_daemon.c
@@ -236,7 +236,7 @@ static int write_pidfile (int fd) /* {{{ */
   fh = fdopen (fd, "w");
   if (fh == NULL)
-    RRDD_LOG (LOG_ERR, "write_pidfile: fopen() failed.");
+    RRDD_LOG (LOG_ERR, "write_pidfile: fdopen() failed.");
     return (-1);

More information about the rrd-developers mailing list