title: Best way to communicate from KEXT to Daemon and block until result is returned from Daemon
body: <p>In KEXT, I am listening for file close via vnode or file scope listener. For certain (very few) files, I need to send file path to my system daemon which does some processing (this has to happen in daemon) and returns the result back to KEXT. The file close call needs to be blocked until I get response from daemon. Based on result I need to some operation in close call and return close call successfully. There is lot of discussion on KEXT communication related topic on the forum. But they are not conclusive and appears be very old (year 2002 around). This requirement can be handled by <code>FtlSendMessage(...)</code> Win32 API. I am looking for equivalent of that on Mac</p>
  
  <p>Here is what I have looked at and want to summarize my understanding:</p>
  
  <ol>
  <li><strong>Mach message</strong>: Provides very good way of bidirectional communication using sender and reply ports with queueing mechansim. However, the mach message APIs (e.g. <code>mach_msg</code>, <code>mach_port_allocate</code>, <code>bootstrap_look_up</code>) don't appear to be KPIs. The mach API <code>mach_msg_send_from_kernel</code> can be used, but that alone will not help in bidirectional communication. Is my understanding right? </li>
  <li><strong>IOUserClient</strong>: This appears be more to do with communicating from User space to KEXT and then having some callbacks from KEXT. I did not find a way to initiate communication from KEXT to daemon and then wait for result from daemon. Am I missing something?</li>
  <li><strong>Sockets</strong>: This could be last option since I would have to implement entire bidirectional communication channel from KEXT to Daemon.</li>
  <li><code>ioct</code>l/<code>sysctl</code>: I don't know much about them. From what I have read, its not recommended option especially for bidirectional communication</li>
  <li><strong>RPC-Mig</strong>: Again I don't know much about them. Looks complicated from what I have seen. Not sure if this is recommended way.        </li>
  <li><strong>KUNCUserNotification</strong>: This appears to be just providing notification to the user from KEXT. It does not meet my requirement.</li>
  </ol>
  
  <p>Supported platform is (10.5 onwards). So looking at the requirement, can someone suggest and provide some pointers on this topic?</p>
  
  <p>Thanks in advance.</p>