From a9f4ec26c8594df7410fa0e22dd7044d9ac6d5c6 Mon Sep 17 00:00:00 2001 From: Hyejin Kim Date: Sun, 15 Mar 2015 19:29:15 -0500 Subject: I added error handling code in write_rotate(). I think that it is better to check tf->logfd before doing truncate()/write() and getting error. --- toys/pending/syslogd.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'toys/pending/syslogd.c') diff --git a/toys/pending/syslogd.c b/toys/pending/syslogd.c index 7fb297f8..450bd72f 100644 --- a/toys/pending/syslogd.c +++ b/toys/pending/syslogd.c @@ -300,6 +300,10 @@ static int write_rotate(struct logfile *tf, int len) unlink(tf->filename); close(tf->logfd); tf->logfd = open(tf->filename, O_CREAT | O_WRONLY | O_APPEND, 0666); + if (tf->logfd < 0) { + perror_msg("can't open %s", tf->filename); + return -1; + } } ftruncate(tf->logfd, 0); } -- cgit v1.2.3