Commit 4e4b48fa by Andy Getzendanner Committed by Copybara-Service

Note that AsyncSignalSafeWriteToStderr preserves errno, and inline one use of it into a lambda.

PiperOrigin-RevId: 535245982
Change-Id: I816f60c8b6476536df6836500f01c9a3ad88ddd4
parent c3e9485b
...@@ -129,7 +129,7 @@ void RawLog(absl::LogSeverity severity, const char* file, int line, ...@@ -129,7 +129,7 @@ void RawLog(absl::LogSeverity severity, const char* file, int line,
const char* format, ...) ABSL_PRINTF_ATTRIBUTE(4, 5); const char* format, ...) ABSL_PRINTF_ATTRIBUTE(4, 5);
// Writes the provided buffer directly to stderr, in a signal-safe, low-level // Writes the provided buffer directly to stderr, in a signal-safe, low-level
// manner. // manner. Preserves errno.
void AsyncSignalSafeWriteToStderr(const char* s, size_t len); void AsyncSignalSafeWriteToStderr(const char* s, size_t len);
// compile-time function to get the "base" filename, that is, the part of // compile-time function to get the "base" filename, that is, the part of
......
...@@ -236,10 +236,6 @@ static void InstallOneFailureHandler(FailureSignalData* data, ...@@ -236,10 +236,6 @@ static void InstallOneFailureHandler(FailureSignalData* data,
#endif #endif
static void WriteToStderr(const char* data) {
absl::raw_log_internal::AsyncSignalSafeWriteToStderr(data, strlen(data));
}
static void WriteSignalMessage(int signo, int cpu, static void WriteSignalMessage(int signo, int cpu,
void (*writerfn)(const char*)) { void (*writerfn)(const char*)) {
char buf[96]; char buf[96];
...@@ -380,7 +376,11 @@ static void AbslFailureSignalHandler(int signo, siginfo_t*, void* ucontext) { ...@@ -380,7 +376,11 @@ static void AbslFailureSignalHandler(int signo, siginfo_t*, void* ucontext) {
#endif #endif
// First write to stderr. // First write to stderr.
WriteFailureInfo(signo, ucontext, my_cpu, WriteToStderr); WriteFailureInfo(
signo, ucontext, my_cpu, +[](const char* data) {
absl::raw_log_internal::AsyncSignalSafeWriteToStderr(data,
strlen(data));
});
// Riskier code (because it is less likely to be async-signal-safe) // Riskier code (because it is less likely to be async-signal-safe)
// goes after this point. // goes after this point.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment