<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <link rel="stylesheet" href="style.css" type="text/css"> <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"> <link rel="Start" href="index.html"> <link rel="Up" href="index.html"> <link title="Index of exceptions" rel=Appendix href="index_exceptions.html"> <link title="Index of values" rel=Appendix href="index_values.html"> <link title="Index of modules" rel=Appendix href="index_modules.html"> <link title="Fd" rel="Chapter" href="Fd.html"><title>Fd</title> </head> <body> <div class="navbar"> <a href="index.html">Up</a> </div> <center><h1>Module <a href="type_Fd.html">Fd</a></h1></center> <br> <pre><span class="keyword">module</span> Fd: <code class="code">sig</code> <a href="Fd.html">..</a> <code class="code">end</code></pre>This module implements miscellaneous functions related to UNIX file descriptors. Currently, the functions listed below are implemented. <p> <ul> <li><a href="Fd.html#VALsend_fd"><code class="code">Fd.send_fd</code></a> and <a href="Fd.html#VALrecv_fd"><code class="code">Fd.recv_fd</code></a>, which are respectively used to send and receive descriptors. Tipically, this functionality is used to allow a process to perform all the actions needed to acquire a descriptor, which is then sent to another process, which will then handle the data transfer operations on that descriptor.</li> <li><a href="Fd.html#VALfexecve"><code class="code">Fd.fexecve</code></a>, which is used to execute a program specified via a file descriptor.</li> </ul> <br> <hr width="100%"> <pre><span class="keyword">exception</span> <a name="EXCEPTIONFd_error"></a>Fd_error <span class="keyword">of</span> <code class="type">string</code></pre> <div class="info"> This exception is raised by <a href="Fd.html#VALsend_fd"><code class="code">Fd.send_fd</code></a> and <a href="Fd.html#VALrecv_fd"><code class="code">Fd.recv_fd</code></a> when an error is encountered. The string contains the error message.<br> </div> <pre><span class="keyword">val</span> <a name="VALsend_fd"></a>send_fd : <code class="type">conn:Unix.file_descr -> fd:Unix.file_descr -> unit</code></pre><div class="info"> This function sends a descriptor over a Unix socket whose peer may be another process. The peer must receive the file descriptor with the function <a href="Fd.html#VALrecv_fd"><code class="code">Fd.recv_fd</code></a> defined in this module. <p> The descriptor is sent as a sized message, so the user application may use the connection to other communication needs.<br> <b>Raises</b> <code>Fd_error</code> This exception is raised on error.<br> </div> <div class="param_info"><code class="code">conn</code> : The connection through which the descriptor will be sent.</div> <div class="param_info"><code class="code">fd</code> : The descriptor to be sent.</div> <pre><span class="keyword">val</span> <a name="VALrecv_fd"></a>recv_fd : <code class="type">conn:Unix.file_descr -> Unix.file_descr</code></pre><div class="info"> This function receives a descriptor sent by <a href="Fd.html#VALsend_fd"><code class="code">Fd.send_fd</code></a>.<br> <b>Raises</b> <code>Fd_error</code> This exception is raised on error.<br> <b>Returns</b> The received file descriptor.<br> </div> <div class="param_info"><code class="code">conn</code> : The connection through which the descriptor will be received.</div> <pre><span class="keyword">val</span> <a name="VALfexecve"></a>fexecve : <code class="type">fd:Unix.file_descr -> args:string array -> env:string array -> 'a</code></pre><div class="info"> This function works like <code class="code">Unix.execve</code>, but the program to be executed, its first paramenter, is specified via a file descriptor. As is the case with the <code class="code">Unix.execv*</code> functions, <a href="Fd.html#VALfexecve"><code class="code">Fd.fexecve</code></a> never returns. If the call succeeds, the current process is substituted by the new one.<br> <b>Raises</b> <code>Fd_error</code> This exception is raised on error.<br> </div> <div class="param_info"><code class="code">fd</code> : The file descriptor corresponding to the program to be executed.</div> <div class="param_info"><code class="code">args</code> : An array of arguments to be passed to the program.</div> <div class="param_info"><code class="code">env</code> : The environment to the program.</div> <pre><span class="keyword">val</span> <a name="VALread_cred"></a>read_cred : <code class="type">fd:Unix.file_descr -> int * int * int</code></pre><div class="info"> This function reads sender credentials from a descriptor. The descriptor must be associated to a UNIX socket. Currently only Linux is supported.<br> <b>Raises</b> <code>Fd_error</code> This exception is raised on error.<br> <b>Returns</b> A tuple of integers containing the sender PID, UID and GID.<br> </div> <div class="param_info"><code class="code">fd</code> : The file descriptor to read the credentials from.</div> </body></html>