File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -573,7 +573,7 @@ pub const vm_region_submap_short_info_64 = extern struct {
573573
574574pub const thread_act_t = mach_port_t ;
575575pub const thread_state_t = * natural_t ;
576- pub const mach_port_array_t = * mach_port_t ;
576+ pub const mach_port_array_t = [ * ] mach_port_t ;
577577
578578pub extern "c" fn task_threads (
579579 target_task : mach_port_t ,
Original file line number Diff line number Diff line change @@ -438,6 +438,18 @@ const mach_task = if (builtin.target.isDarwin()) struct {
438438 },
439439 }
440440 }
441+
442+ pub fn getThreads (task : MachTask ) MachError ! []std.c.mach_port_t {
443+ var thread_list : std.c.mach_port_array_t = undefined ;
444+ var thread_count : std.c.mach_msg_type_number_t = undefined ;
445+ switch (std .c .getKernError (std .c .task_threads (task .port , & thread_list , & thread_count ))) {
446+ .SUCCESS = > return thread_list [0.. thread_count ],
447+ else = > | err | {
448+ log .err ("task_threads kernel call failed with error code: {s}" , .{@tagName (err )});
449+ return error .Unexpected ;
450+ },
451+ }
452+ }
441453 };
442454
443455 pub fn machTaskForPid (pid : std.os.pid_t ) MachError ! MachTask {
You can’t perform that action at this time.
0 commit comments