Function - Request notification of the specified port event type.
kern_return_t mach_port_request_notification
(ipc_space_t task,
mach_port_name_t name,
mach_msg_id_t variant,
mach_port_mscount_t sync,
mach_port_send_once_t notify,
mach_msg_type_name_t notify_type,
mach_port_send_once_t *previous);
The mach_port_request_notification function registers a request for a notification and supplies a send-once right that the notification will use. It is an atomic swap, returning the previously registered send-once right (or MACH_PORT_NULL for none). A notification request may be cancelled by providing MACH_PORT_NULL.
The variant argument takes the following values:
Whenever a dead-name notification is generated, the user reference count of the dead name is incremented. For example, a send right with two user refs has a registered dead-name request. If the port is destroyed, the send right turns into a dead name with three user refs (instead of two), and a dead-name notification is generated.
If the name is made available for reuse, perhaps because of mach_port_destroy or mach_port_mod_refs, or the name denotes a send-once right which has a message sent to it, then the registered send-once right is used to generate a port-deleted notification instead.
The no-senders notification carries the value the port's make-send count had when it was generated. The make-send count is incremented whenever a send right is made directly from a receive right. The make-send count is reset to zero when the receive right is carried in a message.
When moving a receive right, no-senders notifications are canceled, with a send-once notification sent to indicate the cancelation.
This interface is machine word length specific because of the port name parameter.
When using MACH_NOTIFY_DEAD_NAME:
Functions: mach_msg, mach_port_get_attributes.