aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-12-12 17:18:29 -0800
committerAndrew Kelley <andrew@ziglang.org>2025-12-23 22:15:09 -0800
commite68ae8d7a1e78a25392e271d7ca894e0f09aa218 (patch)
treeb22e9e6b67cc782635e614e0a010179f5c3c4d7d /lib
parent54e4a3456ce2d5a497a166b94737fe5407052921 (diff)
downloadzig-e68ae8d7a1e78a25392e271d7ca894e0f09aa218.tar.gz
zig-e68ae8d7a1e78a25392e271d7ca894e0f09aa218.zip
update uses of std.debug.lockStdErr
Diffstat (limited to 'lib')
-rw-r--r--lib/compiler/test_runner.zig17
-rw-r--r--lib/std/debug/simple_panic.zig6
-rw-r--r--lib/std/process.zig24
3 files changed, 26 insertions, 21 deletions
diff --git a/lib/compiler/test_runner.zig b/lib/compiler/test_runner.zig
index b0ef17a7e9..f7f59a5bf3 100644
--- a/lib/compiler/test_runner.zig
+++ b/lib/compiler/test_runner.zig
@@ -405,15 +405,22 @@ pub fn fuzz(
testOne(ctx, input.toSlice()) catch |err| switch (err) {
error.SkipZigTest => return,
else => {
- std.debug.lockStdErr();
- if (@errorReturnTrace()) |trace| std.debug.dumpStackTrace(trace);
- std.debug.print("failed with error.{t}\n", .{err});
+ const stderr = std.debug.lockStderrWriter(&.{});
+ p: {
+ if (@errorReturnTrace()) |trace| {
+ std.debug.writeStackTrace(trace, &stderr.interface, stderr.mode) catch break :p;
+ }
+ stderr.interface.print("failed with error.{t}\n", .{err}) catch break :p;
+ stderr.interface.flush() catch break :p;
+ }
+ stderr.interface.flush() catch {};
std.process.exit(1);
},
};
if (log_err_count != 0) {
- std.debug.lockStdErr();
- std.debug.print("error logs detected\n", .{});
+ const stderr = std.debug.lockStderrWriter(&.{});
+ stderr.interface.print("error logs detected\n", .{}) catch {};
+ stderr.interface.flush() catch {};
std.process.exit(1);
}
}
diff --git a/lib/std/debug/simple_panic.zig b/lib/std/debug/simple_panic.zig
index f6ff77e04f..2d0e5abf4e 100644
--- a/lib/std/debug/simple_panic.zig
+++ b/lib/std/debug/simple_panic.zig
@@ -14,9 +14,9 @@ const std = @import("../std.zig");
pub fn call(msg: []const u8, ra: ?usize) noreturn {
@branchHint(.cold);
_ = ra;
- std.debug.lockStdErr();
- const stderr: std.Io.File = .stderr();
- stderr.writeAll(msg) catch {};
+ const stderr = std.debug.lockStderrWriter(&.{});
+ stderr.interface.writeAll(msg) catch {};
+ stderr.interface.flush(msg) catch {};
@trap();
}
diff --git a/lib/std/process.zig b/lib/std/process.zig
index 5c6e6f89eb..216e793cbe 100644
--- a/lib/std/process.zig
+++ b/lib/std/process.zig
@@ -1841,21 +1841,19 @@ pub fn totalSystemMemory() TotalSystemMemoryError!u64 {
}
}
-/// Indicate that we are now terminating with a successful exit code.
-/// In debug builds, this is a no-op, so that the calling code's
-/// cleanup mechanisms are tested and so that external tools that
-/// check for resource leaks can be accurate. In release builds, this
-/// calls exit(0), and does not return.
-pub fn cleanExit() void {
- if (builtin.mode == .Debug) {
- return;
- } else {
- std.debug.lockStdErr();
- exit(0);
- }
+/// Indicate intent to terminate with a successful exit code.
+///
+/// In debug builds, this is a no-op, so that the calling code's cleanup
+/// mechanisms are tested and so that external tools checking for resource
+/// leaks can be accurate. In release builds, this calls `exit` with code zero,
+/// and does not return.
+pub fn cleanExit(io: Io) void {
+ if (builtin.mode == .Debug) return;
+ _ = io.lockStderrWriter(&.{});
+ exit(0);
}
-/// Raise the open file descriptor limit.
+/// Request ability to have more open file descriptors simultaneously.
///
/// On some systems, this raises the limit before seeing ProcessFdQuotaExceeded
/// errors. On other systems, this does nothing.