changeset 1740:ca358f8731ab draft

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.
author Hyejin Kim <hj8296@gmail.com>
date Sun, 15 Mar 2015 19:29:15 -0500
parents 1134cfb98257
children fece3d1f2924
files toys/pending/syslogd.c
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/toys/pending/syslogd.c	Sat Mar 14 12:34:14 2015 -0500
+++ b/toys/pending/syslogd.c	Sun Mar 15 19:29:15 2015 -0500
@@ -300,6 +300,10 @@
         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);
     }