xref: /xnu-8796.121.2/osfmk/man/MP_request_notification.html (revision c54f35ca767986246321eb901baf8f5ff7923f6a)
1*c54f35caSApple OSS Distributions<h2>mach_port_request_notification</h2>
2*c54f35caSApple OSS Distributions<hr>
3*c54f35caSApple OSS Distributions<p>
4*c54f35caSApple OSS Distributions<strong>Function</strong> - Request notification of the specified port event type.
5*c54f35caSApple OSS Distributions<h3>SYNOPSIS</h3>
6*c54f35caSApple OSS Distributions<pre>
7*c54f35caSApple OSS Distributions<strong>kern_return_t   mach_port_request_notification</strong>
8*c54f35caSApple OSS Distributions                <strong>(ipc_space_t</strong>                               <var>task</var>,
9*c54f35caSApple OSS Distributions                 <strong>mach_port_name_t</strong>                          <var>name</var>,
10*c54f35caSApple OSS Distributions                 <strong>mach_msg_id_t</strong>                          <var>variant</var>,
11*c54f35caSApple OSS Distributions                 <strong>mach_port_mscount_t</strong>                       <var>sync</var>,
12*c54f35caSApple OSS Distributions                 <strong>mach_port_send_once_t</strong>                   <var>notify</var>,
13*c54f35caSApple OSS Distributions                 <strong>mach_msg_type_name_t</strong>               <var>notify_type</var>,
14*c54f35caSApple OSS Distributions                 <strong>mach_port_send_once_t</strong>                <var>*previous</var><strong>);</strong>
15*c54f35caSApple OSS Distributions</pre>
16*c54f35caSApple OSS Distributions<h3>PARAMETERS</h3>
17*c54f35caSApple OSS Distributions<dl>
18*c54f35caSApple OSS Distributions<p>
19*c54f35caSApple OSS Distributions<dt> <var>task</var>
20*c54f35caSApple OSS Distributions<dd>
21*c54f35caSApple OSS Distributions[in task send right]
22*c54f35caSApple OSS DistributionsThe task holding the specified right.
23*c54f35caSApple OSS Distributions<p>
24*c54f35caSApple OSS Distributions<dt> <var>name</var>
25*c54f35caSApple OSS Distributions<dd>
26*c54f35caSApple OSS Distributions[in scalar]
27*c54f35caSApple OSS DistributionsThe task's name for the right.
28*c54f35caSApple OSS Distributions<p>
29*c54f35caSApple OSS Distributions<dt> <var>variant</var>
30*c54f35caSApple OSS Distributions<dd>
31*c54f35caSApple OSS Distributions[in scalar]
32*c54f35caSApple OSS DistributionsThe type of notification.
33*c54f35caSApple OSS Distributions<p>
34*c54f35caSApple OSS Distributions<dt> <var>sync</var>
35*c54f35caSApple OSS Distributions<dd>
36*c54f35caSApple OSS Distributions[in scalar]
37*c54f35caSApple OSS DistributionsSome variants use this value to overcome race conditions.
38*c54f35caSApple OSS Distributions<p>
39*c54f35caSApple OSS Distributions<dt> <var>notify</var>
40*c54f35caSApple OSS Distributions<dd>
41*c54f35caSApple OSS Distributions[in notify send-once or receive (to be converted to send-once) right]
42*c54f35caSApple OSS DistributionsA
43*c54f35caSApple OSS Distributionssend-once right, to which the notification will be sent.
44*c54f35caSApple OSS Distributions<p>
45*c54f35caSApple OSS Distributions<dt> <var>notify_type</var>
46*c54f35caSApple OSS Distributions<dd>
47*c54f35caSApple OSS Distributions[in scalar]
48*c54f35caSApple OSS DistributionsIPC type of the <var>notify</var> right; either
49*c54f35caSApple OSS Distributions<strong>MACH_MSG_TYPE_MAKE_SEND_ONCE</strong> or <strong>MACH_MSG_TYPE_MOVE_SEND_ONCE</strong>.
50*c54f35caSApple OSS Distributions<p>
51*c54f35caSApple OSS Distributions<dt> <var>previous</var>
52*c54f35caSApple OSS Distributions<dd>
53*c54f35caSApple OSS Distributions[out notify send-once right]
54*c54f35caSApple OSS DistributionsThe previously registered send-once right.
55*c54f35caSApple OSS Distributions</dl>
56*c54f35caSApple OSS Distributions<h3>DESCRIPTION</h3>
57*c54f35caSApple OSS Distributions<p>
58*c54f35caSApple OSS DistributionsThe <strong>mach_port_request_notification</strong> function registers a request for a
59*c54f35caSApple OSS Distributionsnotification and supplies a send-once right that the notification
60*c54f35caSApple OSS Distributionswill use.  It is an atomic
61*c54f35caSApple OSS Distributionsswap, returning the previously registered send-once right (or
62*c54f35caSApple OSS Distributions<strong>MACH_PORT_NULL</strong> for none).  A notification request may be
63*c54f35caSApple OSS Distributionscancelled by providing <strong>MACH_PORT_NULL</strong>.
64*c54f35caSApple OSS Distributions<p>
65*c54f35caSApple OSS DistributionsThe <var>variant</var> argument takes the following values:
66*c54f35caSApple OSS Distributions<dl>
67*c54f35caSApple OSS Distributions<dt> <strong>MACH_NOTIFY_PORT_DESTROYED</strong>
68*c54f35caSApple OSS Distributions<dd>
69*c54f35caSApple OSS Distributions<var>sync</var> must be zero.  The <var>name</var> must specify a receive right,
70*c54f35caSApple OSS Distributionsand the call requests a port-destroyed notification for the receive
71*c54f35caSApple OSS Distributionsright.  If the receive right were to have been destroyed, for instance
72*c54f35caSApple OSS Distributionsby <strong>mach_port_destroy</strong>, then instead the receive right will be
73*c54f35caSApple OSS Distributionssent in a port-destroyed notification to the registered send-once right.
74*c54f35caSApple OSS Distributions<p>
75*c54f35caSApple OSS Distributions<dt> <strong>MACH_NOTIFY_DEAD_NAME</strong>
76*c54f35caSApple OSS Distributions<dd>
77*c54f35caSApple OSS DistributionsThe call requests a dead-name notification.  <var>name</var> specifies send,
78*c54f35caSApple OSS Distributionsreceive, or send-once rights for a port.  If the port is destroyed (and the
79*c54f35caSApple OSS Distributionsright remains, becoming a dead name), then a dead-name notification
80*c54f35caSApple OSS Distributionswhich carries the name of the right will be sent to the registered
81*c54f35caSApple OSS Distributionssend-once right.  If <var>sync</var> is non-zero,
82*c54f35caSApple OSS Distributionsthe <var>name</var> may specify a dead name, and
83*c54f35caSApple OSS Distributionsa dead-name notification is immediately generated.
84*c54f35caSApple OSS Distributions<p>
85*c54f35caSApple OSS DistributionsWhenever a dead-name notification is generated, the user reference
86*c54f35caSApple OSS Distributionscount of the dead name is incremented.  For example, a send right with
87*c54f35caSApple OSS Distributionstwo user refs has a registered dead-name request.  If the port is
88*c54f35caSApple OSS Distributionsdestroyed, the send right turns into a dead name with three user refs
89*c54f35caSApple OSS Distributions(instead of two), and a dead-name notification is generated.
90*c54f35caSApple OSS Distributions<p>
91*c54f35caSApple OSS DistributionsIf the name is made available for reuse, perhaps because of
92*c54f35caSApple OSS Distributions<strong>mach_port_destroy</strong> or <strong>mach_port_mod_refs</strong>,
93*c54f35caSApple OSS Distributionsor the name denotes a
94*c54f35caSApple OSS Distributionssend-once right which has a message sent to it, then the registered send-once
95*c54f35caSApple OSS Distributionsright is used to generate a port-deleted notification instead.
96*c54f35caSApple OSS Distributions<p>
97*c54f35caSApple OSS Distributions<dt> <strong>MACH_NOTIFY_NO_SENDERS</strong>
98*c54f35caSApple OSS Distributions<dd>
99*c54f35caSApple OSS DistributionsThe call requests a no-senders notification.  <var>name</var> must specify a
100*c54f35caSApple OSS Distributionsreceive right.  If the receive right's make-send count is greater than or
101*c54f35caSApple OSS Distributionsequal to the sync value, and it has no extant send rights, than an
102*c54f35caSApple OSS Distributionsimmediate no-senders notification is generated.  Otherwise the notification is
103*c54f35caSApple OSS Distributionsgenerated when the receive right next loses its last extant send right.  In
104*c54f35caSApple OSS Distributionseither case, any previously registered send-once right is returned.
105*c54f35caSApple OSS Distributions<p>
106*c54f35caSApple OSS DistributionsThe no-senders notification carries the value the port's make-send
107*c54f35caSApple OSS Distributionscount had when it was generated.  The make-send count is incremented
108*c54f35caSApple OSS Distributionswhenever a send right is made directly from a receive right.  The
109*c54f35caSApple OSS Distributionsmake-send count is reset to zero when the receive right is carried in a
110*c54f35caSApple OSS Distributionsmessage.
111*c54f35caSApple OSS Distributions<p>
112*c54f35caSApple OSS DistributionsWhen moving a receive right, no-senders notifications are canceled,
113*c54f35caSApple OSS Distributionswith a send-once notification sent to indicate the cancelation.
114*c54f35caSApple OSS Distributions</dl>
115*c54f35caSApple OSS Distributions<h3>NOTES</h3>
116*c54f35caSApple OSS Distributions<p>
117*c54f35caSApple OSS DistributionsThis interface is machine word length specific because of the port name
118*c54f35caSApple OSS Distributionsparameter.
119*c54f35caSApple OSS Distributions<h3>RETURN VALUES</h3>
120*c54f35caSApple OSS Distributions<dl>
121*c54f35caSApple OSS Distributions<p>
122*c54f35caSApple OSS Distributions<dt> <strong>KERN_INVALID_NAME</strong>
123*c54f35caSApple OSS Distributions<dd>
124*c54f35caSApple OSS Distributions<var>name</var> did not denote a right.
125*c54f35caSApple OSS Distributions<p>
126*c54f35caSApple OSS Distributions<dt> <strong>KERN_INVALID_RIGHT</strong>
127*c54f35caSApple OSS Distributions<dd>
128*c54f35caSApple OSS Distributions<var>name</var> denoted an invalid right.
129*c54f35caSApple OSS Distributions<p>
130*c54f35caSApple OSS Distributions<dt> <strong>KERN_INVALID_CAPABILITY</strong>
131*c54f35caSApple OSS Distributions<dd>
132*c54f35caSApple OSS Distributions<var>notify</var> was invalid.
133*c54f35caSApple OSS Distributions</dl>
134*c54f35caSApple OSS Distributions<p>
135*c54f35caSApple OSS DistributionsWhen using <strong>MACH_NOTIFY_DEAD_NAME</strong>:
136*c54f35caSApple OSS Distributions<dl>
137*c54f35caSApple OSS Distributions<p>
138*c54f35caSApple OSS Distributions<dt> <strong>KERN_UREFS_OVERFLOW</strong>
139*c54f35caSApple OSS Distributions<dd>
140*c54f35caSApple OSS Distributions<var>name</var> denotes a dead name, but generating an immediate dead-name
141*c54f35caSApple OSS Distributionsnotification would overflow the name's user-reference count.
142*c54f35caSApple OSS Distributions</dl>
143*c54f35caSApple OSS Distributions<h3>RELATED INFORMATION</h3>
144*c54f35caSApple OSS Distributions<p>
145*c54f35caSApple OSS DistributionsFunctions:
146*c54f35caSApple OSS Distributions<a href="mach_msg.html"><strong>mach_msg</strong></a>,
147*c54f35caSApple OSS Distributions<a href="mach_port_get_attributes.html"><strong>mach_port_get_attributes</strong></a>.
148