Module Fd


module Fd: sig .. end
This module implements miscellaneous functions related to UNIX file descriptors. Currently, the functions listed below are implemented.



exception Fd_error of string
This exception is raised by Fd.send_fd and Fd.recv_fd when an error is encountered. The string contains the error message.
val send_fd : conn:Unix.file_descr -> fd:Unix.file_descr -> unit
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 Fd.recv_fd defined in this module.

The descriptor is sent as a sized message, so the user application may use the connection to other communication needs.
Raises Fd_error This exception is raised on error.

conn : The connection through which the descriptor will be sent.
fd : The descriptor to be sent.
val recv_fd : conn:Unix.file_descr -> Unix.file_descr
This function receives a descriptor sent by Fd.send_fd.
Raises Fd_error This exception is raised on error.
Returns The received file descriptor.
conn : The connection through which the descriptor will be received.
val fexecve : fd:Unix.file_descr -> args:string array -> env:string array -> 'a
This function works like Unix.execve, but the program to be executed, its first paramenter, is specified via a file descriptor. As is the case with the Unix.execv* functions, Fd.fexecve never returns. If the call succeeds, the current process is substituted by the new one.
Raises Fd_error This exception is raised on error.
fd : The file descriptor corresponding to the program to be executed.
args : An array of arguments to be passed to the program.
env : The environment to the program.