osfmk/man/task_threads.html
Function - Return the target task's list of threads.
**kern\_return\_t task\_threads**** (task\_t **task,** thread\_act\_port\_array\_t **thread\_list,** mach\_msg\_type\_number\_t\ ***thread\_count** );**
task[in task send right] The port for the task for which the thread list is to be returned.
thread_list[out pointer to dynamic array of thread send rights] The returned list of threads within task, in no particular order.
thread_count[out scalar] The returned count of threads in thread_list.
The task_threads function returns a list of the threads within task. The calling task or thread also receives a send right to the kernel port for each listed thread.
Only generic errors apply.
Functions: thread_create, thread_terminate, thread_suspend.