title: Is there a trick to pass a file descriptor to another process?
body: <p>Here is my trouble.</p>
  
  <p>Facts: </p>
  
  <pre><code>1. There is a device placed in /dev/xxx. 
     All files under /dev/ should have permission of 700 
     (root permission only accessible. No ownership change and group setting)
  
  2. Not-root user application 'A' needs to open /dev/xxx and 
     perform ioctl on the FD.
  </code></pre>
  
  <p>I've come to think several options:</p>
  
  <pre><code>option 1) Write a stub application 'X' that can run with root. 
            Open /dev/xxx in 'X' and perform IPC between A and X.
  </code></pre>
  
  <p>This option is not actually a good one due to the IPC overhead, because A needs to do ioctl extremely frequently.</p>
  
  <pre><code>option 2) Change the location of /dev/xxx into some other place like
            /data/xxx where /data/ is accessible by 'A'
  </code></pre>
  
  <p>For some reason, if I try to open this /data/xxx with valid persmission, the open function returns permission denied error. I don't understand why this happens. Is there some additional protection by kernel for opening device file in some place else in /dev?</p>
  
  <pre><code>option 3) Write a stub application 'X' that can run with root.
            Open /dev/xxx in 'X' and pass the FD to 'A'.
  </code></pre>
  
  <p>I'm not sure this is a plausible option. I hope if you could give any comments on this option.</p>