From 70582a0ced941c8c2ea01028ccdd98a3386971e3 Mon Sep 17 00:00:00 2001 From: oetiker Date: Sun, 7 Jun 2009 14:19:04 +0000 Subject: [PATCH] check return values of dup and ftruncate git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1850 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/src/rrd_daemon.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/program/src/rrd_daemon.c b/program/src/rrd_daemon.c index 53904a33..f997d3ce 100644 --- a/program/src/rrd_daemon.c +++ b/program/src/rrd_daemon.c @@ -379,7 +379,13 @@ static int check_pidfile(void) } lseek(pid_fd, 0, SEEK_SET); - ftruncate(pid_fd, 0); + if (ftruncate(pid_fd, 0) == -1) + { + fprintf(stderr, + "FATAL: Faild to truncate stale PID file. (pid %d)\n", pid); + close(pid_fd); + return -1; + } fprintf(stderr, "rrdcached: removed stale PID file (no rrdcached on pid %d)\n" @@ -2446,8 +2452,9 @@ static int daemonize (void) /* {{{ */ close (0); open ("/dev/null", O_RDWR); - dup (0); - dup (0); + if (dup(0) == -1 || dup(0) == -1){ + RRDD_LOG (LOG_ERR, "faild to run dup.\n"); + } } /* if (!stay_foreground) */ /* Change into the /tmp directory. */ -- 2.30.2