| 37 | static _Atomic bool g_log_crash_durable = false; |
| 38 | |
| 39 | void cbm_log_set_crash_durable(bool enabled) { |
| 40 | if (enabled) { |
| 41 | /* Best effort by contract: setvbuf is only guaranteed before a stream's |
| 42 | * first operation, so a process that has already written to stderr |
| 43 | * keeps its buffering. The per-line flush in emit_line is what makes |
| 44 | * the durability guarantee hold either way. */ |
| 45 | (void)setvbuf(stderr, NULL, _IONBF, 0); |
| 46 | } |
| 47 | atomic_store_explicit(&g_log_crash_durable, enabled, memory_order_relaxed); |
| 48 | } |
| 49 | |
| 50 | bool cbm_log_crash_durable(void) { |
| 51 | return atomic_load_explicit(&g_log_crash_durable, memory_order_relaxed); |
no outgoing calls
no test coverage detected