From 3bd448574bd1338c39cb4e411696224429ab1faf Mon Sep 17 00:00:00 2001 From: tom doron Date: Mon, 13 Jun 2022 21:05:40 -0700 Subject: [PATCH] flush stderr after printing back traces motivation: make sure stderr buffered is printed out before program exits changes: explicitly call fflush after writing the backtraces --- Sources/Backtrace/Backtrace.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/Backtrace/Backtrace.swift b/Sources/Backtrace/Backtrace.swift index 9d08f2e..1baaf08 100644 --- a/Sources/Backtrace/Backtrace.swift +++ b/Sources/Backtrace/Backtrace.swift @@ -64,6 +64,7 @@ private let errorCallback: CBacktraceErrorCallback? = { private func printBacktrace(signal: CInt) { _ = fputs("Received signal \(signal). Backtrace:\n", stderr) backtrace_full(state, /* skip */ 0, fullCallback, errorCallback, nil) + fflush(stderr) } public enum Backtrace {