aboutsummaryrefslogtreecommitdiff
path: root/src/global.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/global.zig')
-rw-r--r--src/global.zig13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/global.zig b/src/global.zig
index 08cc77fab..536b55be7 100644
--- a/src/global.zig
+++ b/src/global.zig
@@ -80,6 +80,19 @@ pub const Output = struct {
source = Source.init(stdout_stream, stderr_stream);
}
+ pub fn configureNamedThread(thread: std.Thread, name: stringZ) void {
+ if (source_set) return;
+ configureThread();
+
+ // On Linux, thread may be undefined
+ // Fortunately, we can use a different syscall that only affects the current thread
+ if (Environment.isLinux) {
+ _ = std.os.linux.prctl(std.os.PR_SET_NAME, @ptrToInt(name.ptr), 0, 0, 0);
+ } else {
+ thread.setName(name) catch {};
+ }
+ }
+
pub fn set(_source: *Source) void {
source = _source.*;
source_set = true;