diff options
author | Mukund Sivaraman <muks@banu.com> | 2009-09-23 07:18:23 +0530 |
---|---|---|
committer | Mukund Sivaraman <muks@banu.com> | 2009-09-27 08:09:22 +0530 |
commit | 003df7454a5f8bc357127ae48d0022cb8d7274ba (patch) | |
tree | f367925c14c6909c4494b877e874268c894a21c8 /src | |
parent | 616c03a9fbe0a72e65d02dc50b5b4cf500971187 (diff) |
Don't ignore retval of write() in log.c
Diffstat (limited to 'src')
-rw-r--r-- | src/log.c | 23 |
1 files changed, 20 insertions, 3 deletions
@@ -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 |