static void WriteToStderr(const char* message, size_t len) {
// Avoid using cerr from this module since we may get called during
// exit code, and cerr may be partially or fully destroyed by then.
- write(STDERR_FILENO, message, len);
+ fwrite(message, len, 1, stderr);
}
inline void LogDestination::MaybeLogToStderr(LogSeverity severity,
// Make the symlink be relative (in the same dir) so that if the
// entire log directory gets relocated the link is still valid.
const char *linkdest = slash ? (slash + 1) : filename;
- symlink(linkdest, linkpath.c_str()); // silently ignore failures
+ if (symlink(linkdest, linkpath.c_str()) != 0) {
+ // silently ignore failures
+ }
// Make an additional link to the log file in a place specified by
// FLAGS_log_link, if indicated
if (!FLAGS_log_link.empty()) {
linkpath = FLAGS_log_link + "/" + linkname;
unlink(linkpath.c_str()); // delete old one if it exists
- symlink(filename, linkpath.c_str()); // silently ignore failures
+ if (symlink(filename, linkpath.c_str()) != 0) {
+ // silently ignore failures
+ }
}
#endif
}
LogDestination::WaitForSinks(data_);
const char* message = "*** Check failure stack trace: ***\n";
- write(STDERR_FILENO, message, strlen(message));
+ if (write(STDERR_FILENO, message, strlen(message)) < 0) {
+ // Ignore errors.
+ }
Fail();
}
}
// Writes the given data with the size to the standard error.
void WriteToStderr(const char* data, int size) {
- write(STDERR_FILENO, data, size);
+ if (write(STDERR_FILENO, data, size) < 0) {
+ // Ignore errors.
+ }
}
// The writer function can be changed by InstallFailureWriter().
static void DebugWriteToStderr(const char* data, void *unused) {
// This one is signal-safe.
- write(STDERR_FILENO, data, strlen(data));
+ if (write(STDERR_FILENO, data, strlen(data)) < 0) {
+ // Ignore errors.
+ }
}
void DebugWriteToString(const char* data, void *arg) {