summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorMukund Sivaraman <muks@banu.com>2009-09-23 07:18:23 +0530
committerMukund Sivaraman <muks@banu.com>2009-09-27 08:09:22 +0530
commit003df7454a5f8bc357127ae48d0022cb8d7274ba (patch)
treef367925c14c6909c4494b877e874268c894a21c8 /src
parent616c03a9fbe0a72e65d02dc50b5b4cf500971187 (diff)
Don't ignore retval of write() in log.c
Diffstat (limited to 'src')
-rw-r--r--src/log.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/log.c b/src/log.c
index 6f94ab0..5d12c8d 100644
--- a/src/log.c
+++ b/src/log.c
@@ -109,6 +109,8 @@ void log_message (int level, const char *fmt, ...)
char time_string[TIME_LENGTH];
char str[STRING_LENGTH];
+ ssize_t ret;
+
#ifdef NDEBUG
/*
* Figure out if we should write the message or not.
@@ -177,10 +179,25 @@ void log_message (int level, const char *fmt, ...)
assert (log_file_fd >= 0);
- write (log_file_fd, str, strlen (str));
+ ret = write (log_file_fd, str, strlen (str));
+ if (ret == -1) {
+ log_message (LOG_WARNING,
+ "Could not write to log file");
+ }
+
vsnprintf (str, STRING_LENGTH, fmt, args);
- write (log_file_fd, str, strlen (str));
- write (log_file_fd, "\n", 1);
+ ret = write (log_file_fd, str, strlen (str));
+ if (ret == -1) {
+ log_message (LOG_WARNING,
+ "Could not write to log file");
+ }
+
+ ret = write (log_file_fd, "\n", 1);
+ if (ret == -1) {
+ log_message (LOG_WARNING,
+ "Could not write to log file");
+ }
+
fsync (log_file_fd);
#ifdef HAVE_SYSLOG_H