zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit fad223d92ed34caac163695cc2a32cba80267c32 (tree)
parent 506b3f6db6c13bcced94c80ddf9bd871fb721cc0
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Wed, 12 Jun 2024 17:16:42 -0700

std.Progress: use a recursive mutex for stderr

Diffstat:
Mlib/std/Progress.zig | 7++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/std/Progress.zig b/lib/std/Progress.zig @@ -521,6 +521,8 @@ fn windowsApiUpdateThreadRun() void { /// Allows the caller to freely write to stderr until `unlockStdErr` is called. /// /// During the lock, any `std.Progress` information is cleared from the terminal. +/// +/// The lock is recursive; the same thread may hold the lock multiple times. pub fn lockStdErr() void { stderr_mutex.lock(); clearWrittenWithEscapeCodes() catch {}; @@ -1378,4 +1380,7 @@ const have_sigwinch = switch (builtin.os.tag) { else => false, }; -var stderr_mutex: std.Thread.Mutex = .{}; +/// The primary motivation for recursive mutex here is so that a panic while +/// stderr mutex is held still dumps the stack trace and other debug +/// information. +var stderr_mutex = std.Thread.Mutex.Recursive.init;