osfmk/man/mach_ports_lookup.html
Function - Provide caller with an array of the target task's well-known ports.
**kern\_return\_t mach\_ports\_lookup**** (task\_t **target\_task,** mach\_port\_array\_t **init\_port\_set,** mach\_msg\_type\_number\_t **init\_port\_count** );**
target_task[in task send right] The task whose currently registered ports are to be returned.
init_port_set[out pointer to dynamic array of registered send rights] The returned array of ports.
init_port_count[out scalar] The number of returned port rights.
The mach_ports_lookup function returns an array of the well-known system ports that are currently registered for the specified task. Note that the task holds only send rights for the ports.
Registered ports are those ports that are used by the run-time system to initialize a task. To register system ports for a task, use the mach_ports_register function.
Only generic errors apply.
Functions: mach_ports_register.