osfmk/man/thread_get_special_port.html
Function - Return a send right to the caller-specified special port.
**kern\_return\_t thread\_get\_special\_port**** (thread\_act\_t **thread,** int **which\_port,** thread **special\_port** );**
**kern\_return\_t thread\_get\_kernel\_port**** (thread\_act\_t **thread,** thread **special\_port** );**
thread[in thread send right] The thread for which to return the port's send right.
which_port[in scalar] The special port for which the send right is requested. Valid values are:
THREAD_KERNEL_PORT [thread-self send right] The port used to name the thread. Used to invoke operations that affect the thread. This is the movable port for the thread and different from mach_thread_self (immovable).
special_port[out thread-special send right] The returned value for the port.
The thread_get_special_port function returns a send right for a special port belonging to thread.
The thread kernel port is a port for which the kernel holds the receive right. The kernel uses this port to identify the thread.
If one thread has a send right for the kernel port of another thread, it can use the port to perform kernel operations for the other thread. Send rights for a kernel port normally are held only by the thread to which the port belongs, or by the task that contains the thread. Using the mach_msg function, however, any thread can pass a send right for its kernel port to another thread.
Only generic errors apply.
Functions: mach_thread_self, task_get_special_port, task_set_special_port, thread_create, thread_set_special_port.