4791 lines
79 KiB
HTML
4791 lines
79 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of UnixLabels</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>UnixLabels</H1>
|
|
Section: OCaml library (3o)<BR>Updated: 2020-01-30<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
UnixLabels - Interface to the Unix system.
|
|
<A NAME="lbAC"> </A>
|
|
<H2>Module</H2>
|
|
|
|
Module UnixLabels
|
|
<A NAME="lbAD"> </A>
|
|
<H2>Documentation</H2>
|
|
|
|
<P>
|
|
Module
|
|
<B>UnixLabels</B>
|
|
|
|
<BR> :
|
|
<B>sig end</B>
|
|
|
|
<P>
|
|
<P>
|
|
Interface to the Unix system.
|
|
To use as replacement to default
|
|
<B>Unix</B>
|
|
|
|
module,
|
|
add
|
|
<B>module Unix = UnixLabels</B>
|
|
|
|
in your implementation.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAE"> </A>
|
|
<H3>Error report</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<I>type error </I>
|
|
|
|
=
|
|
<B>Unix.error</B>
|
|
|
|
=
|
|
<BR> | E2BIG (* Argument list too long
|
|
<BR> *)
|
|
<BR> | EACCES (* Permission denied
|
|
<BR> *)
|
|
<BR> | EAGAIN (* Resource temporarily unavailable; try again
|
|
<BR> *)
|
|
<BR> | EBADF (* Bad file descriptor
|
|
<BR> *)
|
|
<BR> | EBUSY (* Resource unavailable
|
|
<BR> *)
|
|
<BR> | ECHILD (* No child process
|
|
<BR> *)
|
|
<BR> | EDEADLK (* Resource deadlock would occur
|
|
<BR> *)
|
|
<BR> | EDOM (* Domain error for math functions, etc.
|
|
<BR> *)
|
|
<BR> | EEXIST (* File exists
|
|
<BR> *)
|
|
<BR> | EFAULT (* Bad address
|
|
<BR> *)
|
|
<BR> | EFBIG (* File too large
|
|
<BR> *)
|
|
<BR> | EINTR (* Function interrupted by signal
|
|
<BR> *)
|
|
<BR> | EINVAL (* Invalid argument
|
|
<BR> *)
|
|
<BR> | EIO (* Hardware I/O error
|
|
<BR> *)
|
|
<BR> | EISDIR (* Is a directory
|
|
<BR> *)
|
|
<BR> | EMFILE (* Too many open files by the process
|
|
<BR> *)
|
|
<BR> | EMLINK (* Too many links
|
|
<BR> *)
|
|
<BR> | ENAMETOOLONG (* Filename too long
|
|
<BR> *)
|
|
<BR> | ENFILE (* Too many open files in the system
|
|
<BR> *)
|
|
<BR> | ENODEV (* No such device
|
|
<BR> *)
|
|
<BR> | ENOENT (* No such file or directory
|
|
<BR> *)
|
|
<BR> | ENOEXEC (* Not an executable file
|
|
<BR> *)
|
|
<BR> | ENOLCK (* No locks available
|
|
<BR> *)
|
|
<BR> | ENOMEM (* Not enough memory
|
|
<BR> *)
|
|
<BR> | ENOSPC (* No space left on device
|
|
<BR> *)
|
|
<BR> | ENOSYS (* Function not supported
|
|
<BR> *)
|
|
<BR> | ENOTDIR (* Not a directory
|
|
<BR> *)
|
|
<BR> | ENOTEMPTY (* Directory not empty
|
|
<BR> *)
|
|
<BR> | ENOTTY (* Inappropriate I/O control operation
|
|
<BR> *)
|
|
<BR> | ENXIO (* No such device or address
|
|
<BR> *)
|
|
<BR> | EPERM (* Operation not permitted
|
|
<BR> *)
|
|
<BR> | EPIPE (* Broken pipe
|
|
<BR> *)
|
|
<BR> | ERANGE (* Result too large
|
|
<BR> *)
|
|
<BR> | EROFS (* Read-only file system
|
|
<BR> *)
|
|
<BR> | ESPIPE (* Invalid seek e.g. on a pipe
|
|
<BR> *)
|
|
<BR> | ESRCH (* No such process
|
|
<BR> *)
|
|
<BR> | EXDEV (* Invalid link
|
|
<BR> *)
|
|
<BR> | EWOULDBLOCK (* Operation would block
|
|
<BR> *)
|
|
<BR> | EINPROGRESS (* Operation now in progress
|
|
<BR> *)
|
|
<BR> | EALREADY (* Operation already in progress
|
|
<BR> *)
|
|
<BR> | ENOTSOCK (* Socket operation on non-socket
|
|
<BR> *)
|
|
<BR> | EDESTADDRREQ (* Destination address required
|
|
<BR> *)
|
|
<BR> | EMSGSIZE (* Message too long
|
|
<BR> *)
|
|
<BR> | EPROTOTYPE (* Protocol wrong type for socket
|
|
<BR> *)
|
|
<BR> | ENOPROTOOPT (* Protocol not available
|
|
<BR> *)
|
|
<BR> | EPROTONOSUPPORT (* Protocol not supported
|
|
<BR> *)
|
|
<BR> | ESOCKTNOSUPPORT (* Socket type not supported
|
|
<BR> *)
|
|
<BR> | EOPNOTSUPP (* Operation not supported on socket
|
|
<BR> *)
|
|
<BR> | EPFNOSUPPORT (* Protocol family not supported
|
|
<BR> *)
|
|
<BR> | EAFNOSUPPORT (* Address family not supported by protocol family
|
|
<BR> *)
|
|
<BR> | EADDRINUSE (* Address already in use
|
|
<BR> *)
|
|
<BR> | EADDRNOTAVAIL (* Can't assign requested address
|
|
<BR> *)
|
|
<BR> | ENETDOWN (* Network is down
|
|
<BR> *)
|
|
<BR> | ENETUNREACH (* Network is unreachable
|
|
<BR> *)
|
|
<BR> | ENETRESET (* Network dropped connection on reset
|
|
<BR> *)
|
|
<BR> | ECONNABORTED (* Software caused connection abort
|
|
<BR> *)
|
|
<BR> | ECONNRESET (* Connection reset by peer
|
|
<BR> *)
|
|
<BR> | ENOBUFS (* No buffer space available
|
|
<BR> *)
|
|
<BR> | EISCONN (* Socket is already connected
|
|
<BR> *)
|
|
<BR> | ENOTCONN (* Socket is not connected
|
|
<BR> *)
|
|
<BR> | ESHUTDOWN (* Can't send after socket shutdown
|
|
<BR> *)
|
|
<BR> | ETOOMANYREFS (* Too many references: can't splice
|
|
<BR> *)
|
|
<BR> | ETIMEDOUT (* Connection timed out
|
|
<BR> *)
|
|
<BR> | ECONNREFUSED (* Connection refused
|
|
<BR> *)
|
|
<BR> | EHOSTDOWN (* Host is down
|
|
<BR> *)
|
|
<BR> | EHOSTUNREACH (* No route to host
|
|
<BR> *)
|
|
<BR> | ELOOP (* Too many levels of symbolic links
|
|
<BR> *)
|
|
<BR> | EOVERFLOW (* File size or position not representable
|
|
<BR> *)
|
|
<BR> | EUNKNOWNERR
|
|
<B>of </B>
|
|
|
|
<B>int</B>
|
|
|
|
<I> </I>
|
|
|
|
<BR> (* Unknown error
|
|
<BR> *)
|
|
<BR>
|
|
<P>
|
|
The type of error codes.
|
|
Errors defined in the POSIX standard
|
|
and additional errors from UNIX98 and BSD.
|
|
All other errors are mapped to EUNKNOWNERR.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>exception Unix_error </I>
|
|
|
|
<B>of </B>
|
|
|
|
<B>error * string * string</B>
|
|
|
|
<P>
|
|
<P>
|
|
Raised by the system calls below when an error is encountered.
|
|
The first component is the error code; the second component
|
|
is the function name; the third component is the string parameter
|
|
to the function, if it has one, or the empty string otherwise.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val error_message </I>
|
|
|
|
:
|
|
<B>error -> string</B>
|
|
|
|
<P>
|
|
Return a string describing the given error code.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val handle_unix_error </I>
|
|
|
|
:
|
|
<B>('a -> 'b) -> 'a -> 'b</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>handle_unix_error f x</B>
|
|
|
|
applies
|
|
<B>f</B>
|
|
|
|
to
|
|
<B>x</B>
|
|
|
|
and returns the result.
|
|
If the exception
|
|
<B>Unix_error</B>
|
|
|
|
is raised, it prints a message
|
|
describing the error and exits with code 2.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAF"> </A>
|
|
<H3>Access to the process environment</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<P>
|
|
<I>val environment </I>
|
|
|
|
:
|
|
<B>unit -> string array</B>
|
|
|
|
<P>
|
|
Return the process environment, as an array of strings
|
|
with the format ``variable=value''.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getenv </I>
|
|
|
|
:
|
|
<B>string -> string</B>
|
|
|
|
<P>
|
|
Return the value associated to a variable in the process
|
|
environment. Raise
|
|
<B>Not_found</B>
|
|
|
|
if the variable is unbound.
|
|
(This function is identical to
|
|
<B>Sys.getenv</B>
|
|
|
|
.)
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val unsafe_getenv </I>
|
|
|
|
:
|
|
<B>string -> string</B>
|
|
|
|
<P>
|
|
Return the value associated to a variable in the process
|
|
environment.
|
|
<P>
|
|
Unlike
|
|
<B>UnixLabels.getenv</B>
|
|
|
|
, this function returns the value even if the
|
|
process has special privileges. It is considered unsafe because the
|
|
programmer of a setuid or setgid program must be careful to avoid
|
|
using maliciously crafted environment variables in the search path
|
|
for executables, the locations for temporary files or logs, and the
|
|
like.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.06.0
|
|
<P>
|
|
<P>
|
|
<B>Raises Not_found</B>
|
|
|
|
if the variable is unbound.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val putenv </I>
|
|
|
|
:
|
|
<B>string -> string -> unit</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>Unix.putenv name value</B>
|
|
|
|
sets the value associated to a
|
|
variable in the process environment.
|
|
<B>name</B>
|
|
|
|
is the name of the environment variable,
|
|
and
|
|
<B>value</B>
|
|
|
|
its new associated value.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAG"> </A>
|
|
<H3>Process handling</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<I>type process_status </I>
|
|
|
|
=
|
|
<B>Unix.process_status</B>
|
|
|
|
=
|
|
<BR> | WEXITED
|
|
<B>of </B>
|
|
|
|
<B>int</B>
|
|
|
|
<I> </I>
|
|
|
|
<BR> (* The process terminated normally by
|
|
<B>exit</B>
|
|
|
|
;
|
|
the argument is the return code.
|
|
<BR> *)
|
|
<BR> | WSIGNALED
|
|
<B>of </B>
|
|
|
|
<B>int</B>
|
|
|
|
<I> </I>
|
|
|
|
<BR> (* The process was killed by a signal;
|
|
the argument is the signal number.
|
|
<BR> *)
|
|
<BR> | WSTOPPED
|
|
<B>of </B>
|
|
|
|
<B>int</B>
|
|
|
|
<I> </I>
|
|
|
|
<BR> (* The process was stopped by a signal; the argument is the
|
|
signal number.
|
|
<BR> *)
|
|
<BR>
|
|
<P>
|
|
The termination status of a process. See module
|
|
<B>Sys</B>
|
|
|
|
for the
|
|
definitions of the standard signal numbers. Note that they are
|
|
not the numbers used by the OS.
|
|
<P>
|
|
<P>
|
|
<I>type wait_flag </I>
|
|
|
|
=
|
|
<B>Unix.wait_flag</B>
|
|
|
|
=
|
|
<BR> | WNOHANG (* do not block if no child has
|
|
died yet, but immediately return with a pid equal to 0.
|
|
<BR> *)
|
|
<BR> | WUNTRACED (* report also the children that receive stop signals.
|
|
<BR> *)
|
|
<BR>
|
|
<P>
|
|
Flags for
|
|
<B>UnixLabels.waitpid</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val execv </I>
|
|
|
|
:
|
|
<B>prog:string -> args:string array -> 'a</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>execv prog args</B>
|
|
|
|
execute the program in file
|
|
<B>prog</B>
|
|
|
|
, with
|
|
the arguments
|
|
<B>args</B>
|
|
|
|
, and the current process environment.
|
|
These
|
|
<B>execv*</B>
|
|
|
|
functions never return: on success, the current
|
|
program is replaced by the new one;
|
|
on failure, a
|
|
<B>UnixLabels.Unix_error</B>
|
|
|
|
exception is raised.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val execve </I>
|
|
|
|
:
|
|
<B>prog:string -> args:string array -> env:string array -> 'a</B>
|
|
|
|
<P>
|
|
Same as
|
|
<B>UnixLabels.execv</B>
|
|
|
|
, except that the third argument provides the
|
|
environment to the program executed.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val execvp </I>
|
|
|
|
:
|
|
<B>prog:string -> args:string array -> 'a</B>
|
|
|
|
<P>
|
|
Same as
|
|
<B>UnixLabels.execv</B>
|
|
|
|
, except that
|
|
the program is searched in the path.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val execvpe </I>
|
|
|
|
:
|
|
<B>prog:string -> args:string array -> env:string array -> 'a</B>
|
|
|
|
<P>
|
|
Same as
|
|
<B>UnixLabels.execve</B>
|
|
|
|
, except that
|
|
the program is searched in the path.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val fork </I>
|
|
|
|
:
|
|
<B>unit -> int</B>
|
|
|
|
<P>
|
|
Fork a new process. The returned integer is 0 for the child
|
|
process, the pid of the child process for the parent process.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val wait </I>
|
|
|
|
:
|
|
<B>unit -> int * process_status</B>
|
|
|
|
<P>
|
|
Wait until one of the children processes die, and return its pid
|
|
and termination status.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val waitpid </I>
|
|
|
|
:
|
|
<B>mode:wait_flag list -> int -> int * process_status</B>
|
|
|
|
<P>
|
|
Same as
|
|
<B>UnixLabels.wait</B>
|
|
|
|
, but waits for the child process whose pid
|
|
is given.
|
|
A pid of
|
|
<B>-1</B>
|
|
|
|
means wait for any child.
|
|
A pid of
|
|
<B>0</B>
|
|
|
|
means wait for any child in the same process group
|
|
as the current process.
|
|
Negative pid arguments represent process groups.
|
|
The list of options indicates whether
|
|
<B>waitpid</B>
|
|
|
|
should return
|
|
immediately without waiting, or also report stopped children.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val system </I>
|
|
|
|
:
|
|
<B>string -> process_status</B>
|
|
|
|
<P>
|
|
Execute the given command, wait until it terminates, and return
|
|
its termination status. The string is interpreted by the shell
|
|
<B>/bin/sh</B>
|
|
|
|
and therefore can contain redirections, quotes, variables,
|
|
etc. The result
|
|
<B>WEXITED 127</B>
|
|
|
|
indicates that the shell couldn't
|
|
be executed.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getpid </I>
|
|
|
|
:
|
|
<B>unit -> int</B>
|
|
|
|
<P>
|
|
Return the pid of the process.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getppid </I>
|
|
|
|
:
|
|
<B>unit -> int</B>
|
|
|
|
<P>
|
|
Return the pid of the parent process.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val nice </I>
|
|
|
|
:
|
|
<B>int -> int</B>
|
|
|
|
<P>
|
|
Change the process priority. The integer argument is added to the
|
|
``nice'' value. (Higher values of the ``nice'' value mean
|
|
lower priorities.) Return the new nice value.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAH"> </A>
|
|
<H3>Basic file input/output</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<I>type file_descr </I>
|
|
|
|
=
|
|
<B>Unix.file_descr</B>
|
|
|
|
<P>
|
|
<P>
|
|
The abstract type of file descriptors.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val stdin </I>
|
|
|
|
:
|
|
<B>file_descr</B>
|
|
|
|
<P>
|
|
File descriptor for standard input.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val stdout </I>
|
|
|
|
:
|
|
<B>file_descr</B>
|
|
|
|
<P>
|
|
File descriptor for standard output.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val stderr </I>
|
|
|
|
:
|
|
<B>file_descr</B>
|
|
|
|
<P>
|
|
File descriptor for standard error.
|
|
<P>
|
|
<P>
|
|
<I>type open_flag </I>
|
|
|
|
=
|
|
<B>Unix.open_flag</B>
|
|
|
|
=
|
|
<BR> | O_RDONLY (* Open for reading
|
|
<BR> *)
|
|
<BR> | O_WRONLY (* Open for writing
|
|
<BR> *)
|
|
<BR> | O_RDWR (* Open for reading and writing
|
|
<BR> *)
|
|
<BR> | O_NONBLOCK (* Open in non-blocking mode
|
|
<BR> *)
|
|
<BR> | O_APPEND (* Open for append
|
|
<BR> *)
|
|
<BR> | O_CREAT (* Create if nonexistent
|
|
<BR> *)
|
|
<BR> | O_TRUNC (* Truncate to 0 length if existing
|
|
<BR> *)
|
|
<BR> | O_EXCL (* Fail if existing
|
|
<BR> *)
|
|
<BR> | O_NOCTTY (* Don't make this dev a controlling tty
|
|
<BR> *)
|
|
<BR> | O_DSYNC (* Writes complete as `Synchronised I/O data
|
|
integrity completion'
|
|
<BR> *)
|
|
<BR> | O_SYNC (* Writes complete as `Synchronised I/O file
|
|
integrity completion'
|
|
<BR> *)
|
|
<BR> | O_RSYNC (* Reads complete as writes (depending
|
|
on O_SYNC/O_DSYNC)
|
|
<BR> *)
|
|
<BR> | O_SHARE_DELETE (* Windows only: allow the file to be deleted
|
|
while still open
|
|
<BR> *)
|
|
<BR> | O_CLOEXEC (* Set the close-on-exec flag on the
|
|
descriptor returned by
|
|
<B>UnixLabels.openfile</B>
|
|
|
|
<P>
|
|
<BR> *)
|
|
<BR> | O_KEEPEXEC (* Clear the close-on-exec flag.
|
|
This is currently the default.
|
|
<BR> *)
|
|
<BR>
|
|
<P>
|
|
The flags to
|
|
<B>UnixLabels.openfile</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<I>type file_perm </I>
|
|
|
|
=
|
|
<B>int</B>
|
|
|
|
<P>
|
|
<P>
|
|
The type of file access rights, e.g.
|
|
<B>0o640</B>
|
|
|
|
is read and write for user,
|
|
read for group, none for others
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val openfile </I>
|
|
|
|
:
|
|
<B>string -></B>
|
|
|
|
<B>mode:open_flag list -></B>
|
|
|
|
<B>perm:file_perm -> file_descr</B>
|
|
|
|
<P>
|
|
Open the named file with the given flags. Third argument is
|
|
the permissions to give to the file if it is created. Return
|
|
a file descriptor on the named file.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val close </I>
|
|
|
|
:
|
|
<B>file_descr -> unit</B>
|
|
|
|
<P>
|
|
Close a file descriptor.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val read </I>
|
|
|
|
:
|
|
<B>file_descr -> buf:bytes -> pos:int -> len:int -> int</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>read fd buff ofs len</B>
|
|
|
|
reads
|
|
<B>len</B>
|
|
|
|
bytes from descriptor
|
|
<B>fd</B>
|
|
|
|
,
|
|
storing them in byte sequence
|
|
<B>buff</B>
|
|
|
|
, starting at position
|
|
<B>ofs</B>
|
|
|
|
in
|
|
<B>buff</B>
|
|
|
|
. Return the number of bytes actually read.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val write </I>
|
|
|
|
:
|
|
<B>file_descr -> buf:bytes -> pos:int -> len:int -> int</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>write fd buff ofs len</B>
|
|
|
|
writes
|
|
<B>len</B>
|
|
|
|
bytes to descriptor
|
|
<B>fd</B>
|
|
|
|
,
|
|
taking them from byte sequence
|
|
<B>buff</B>
|
|
|
|
, starting at position
|
|
<B>ofs</B>
|
|
|
|
in
|
|
<B>buff</B>
|
|
|
|
. Return the number of bytes actually written.
|
|
<B>write</B>
|
|
|
|
repeats the writing operation until all bytes have been written or
|
|
an error occurs.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val single_write </I>
|
|
|
|
:
|
|
<B>file_descr -> buf:bytes -> pos:int -> len:int -> int</B>
|
|
|
|
<P>
|
|
Same as
|
|
<B>write</B>
|
|
|
|
, but attempts to write only once.
|
|
Thus, if an error occurs,
|
|
<B>single_write</B>
|
|
|
|
guarantees that no data
|
|
has been written.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val write_substring </I>
|
|
|
|
:
|
|
<B>file_descr -> buf:string -> pos:int -> len:int -> int</B>
|
|
|
|
<P>
|
|
Same as
|
|
<B>write</B>
|
|
|
|
, but take the data from a string instead of a byte
|
|
sequence.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.02.0
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val single_write_substring </I>
|
|
|
|
:
|
|
<B>file_descr -> buf:string -> pos:int -> len:int -> int</B>
|
|
|
|
<P>
|
|
Same as
|
|
<B>single_write</B>
|
|
|
|
, but take the data from a string instead of
|
|
a byte sequence.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.02.0
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAI"> </A>
|
|
<H3>Interfacing with the standard input/output library</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<P>
|
|
<I>val in_channel_of_descr </I>
|
|
|
|
:
|
|
<B>file_descr -> in_channel</B>
|
|
|
|
<P>
|
|
Create an input channel reading from the given descriptor.
|
|
The channel is initially in binary mode; use
|
|
<B>set_binary_mode_in ic false</B>
|
|
|
|
if text mode is desired.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val out_channel_of_descr </I>
|
|
|
|
:
|
|
<B>file_descr -> out_channel</B>
|
|
|
|
<P>
|
|
Create an output channel writing on the given descriptor.
|
|
The channel is initially in binary mode; use
|
|
<B>set_binary_mode_out oc false</B>
|
|
|
|
if text mode is desired.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val descr_of_in_channel </I>
|
|
|
|
:
|
|
<B>in_channel -> file_descr</B>
|
|
|
|
<P>
|
|
Return the descriptor corresponding to an input channel.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val descr_of_out_channel </I>
|
|
|
|
:
|
|
<B>out_channel -> file_descr</B>
|
|
|
|
<P>
|
|
Return the descriptor corresponding to an output channel.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAJ"> </A>
|
|
<H3>Seeking and truncating</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<I>type seek_command </I>
|
|
|
|
=
|
|
<B>Unix.seek_command</B>
|
|
|
|
=
|
|
<BR> | SEEK_SET (* indicates positions relative to the beginning of the file
|
|
<BR> *)
|
|
<BR> | SEEK_CUR (* indicates positions relative to the current position
|
|
<BR> *)
|
|
<BR> | SEEK_END (* indicates positions relative to the end of the file
|
|
<BR> *)
|
|
<BR>
|
|
<P>
|
|
Positioning modes for
|
|
<B>UnixLabels.lseek</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val lseek </I>
|
|
|
|
:
|
|
<B>file_descr -> int -> mode:seek_command -> int</B>
|
|
|
|
<P>
|
|
Set the current position for a file descriptor, and return the resulting
|
|
offset (from the beginning of the file).
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val truncate </I>
|
|
|
|
:
|
|
<B>string -> len:int -> unit</B>
|
|
|
|
<P>
|
|
Truncates the named file to the given size.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val ftruncate </I>
|
|
|
|
:
|
|
<B>file_descr -> len:int -> unit</B>
|
|
|
|
<P>
|
|
Truncates the file corresponding to the given descriptor
|
|
to the given size.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAK"> </A>
|
|
<H3>File status</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<I>type file_kind </I>
|
|
|
|
=
|
|
<B>Unix.file_kind</B>
|
|
|
|
=
|
|
<BR> | S_REG (* Regular file
|
|
<BR> *)
|
|
<BR> | S_DIR (* Directory
|
|
<BR> *)
|
|
<BR> | S_CHR (* Character device
|
|
<BR> *)
|
|
<BR> | S_BLK (* Block device
|
|
<BR> *)
|
|
<BR> | S_LNK (* Symbolic link
|
|
<BR> *)
|
|
<BR> | S_FIFO (* Named pipe
|
|
<BR> *)
|
|
<BR> | S_SOCK (* Socket
|
|
<BR> *)
|
|
<BR>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>type stats </I>
|
|
|
|
=
|
|
<B>Unix.stats</B>
|
|
|
|
= {
|
|
<BR> st_dev :
|
|
<B>int</B>
|
|
|
|
; (* Device number
|
|
<BR> *)
|
|
<BR> st_ino :
|
|
<B>int</B>
|
|
|
|
; (* Inode number
|
|
<BR> *)
|
|
<BR> st_kind :
|
|
<B>file_kind</B>
|
|
|
|
; (* Kind of the file
|
|
<BR> *)
|
|
<BR> st_perm :
|
|
<B>file_perm</B>
|
|
|
|
; (* Access rights
|
|
<BR> *)
|
|
<BR> st_nlink :
|
|
<B>int</B>
|
|
|
|
; (* Number of links
|
|
<BR> *)
|
|
<BR> st_uid :
|
|
<B>int</B>
|
|
|
|
; (* User id of the owner
|
|
<BR> *)
|
|
<BR> st_gid :
|
|
<B>int</B>
|
|
|
|
; (* Group ID of the file's group
|
|
<BR> *)
|
|
<BR> st_rdev :
|
|
<B>int</B>
|
|
|
|
; (* Device ID (if special file)
|
|
<BR> *)
|
|
<BR> st_size :
|
|
<B>int</B>
|
|
|
|
; (* Size in bytes
|
|
<BR> *)
|
|
<BR> st_atime :
|
|
<B>float</B>
|
|
|
|
; (* Last access time
|
|
<BR> *)
|
|
<BR> st_mtime :
|
|
<B>float</B>
|
|
|
|
; (* Last modification time
|
|
<BR> *)
|
|
<BR> st_ctime :
|
|
<B>float</B>
|
|
|
|
; (* Last status change time
|
|
<BR> *)
|
|
<BR> }
|
|
<P>
|
|
<P>
|
|
The information returned by the
|
|
<B>UnixLabels.stat</B>
|
|
|
|
calls.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val stat </I>
|
|
|
|
:
|
|
<B>string -> stats</B>
|
|
|
|
<P>
|
|
Return the information for the named file.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val lstat </I>
|
|
|
|
:
|
|
<B>string -> stats</B>
|
|
|
|
<P>
|
|
Same as
|
|
<B>UnixLabels.stat</B>
|
|
|
|
, but in case the file is a symbolic link,
|
|
return the information for the link itself.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val fstat </I>
|
|
|
|
:
|
|
<B>file_descr -> stats</B>
|
|
|
|
<P>
|
|
Return the information for the file associated with the given
|
|
descriptor.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val isatty </I>
|
|
|
|
:
|
|
<B>file_descr -> bool</B>
|
|
|
|
<P>
|
|
Return
|
|
<B>true</B>
|
|
|
|
if the given file descriptor refers to a terminal or
|
|
console window,
|
|
<B>false</B>
|
|
|
|
otherwise.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAL"> </A>
|
|
<H3>File operations on large files</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<I>module LargeFile : </I>
|
|
|
|
<B>sig end</B>
|
|
|
|
<P>
|
|
<P>
|
|
File operations on large files.
|
|
This sub-module provides 64-bit variants of the functions
|
|
<B>UnixLabels.lseek</B>
|
|
|
|
(for positioning a file descriptor),
|
|
<B>UnixLabels.truncate</B>
|
|
|
|
and
|
|
<B>UnixLabels.ftruncate</B>
|
|
|
|
(for changing the size of a file),
|
|
and
|
|
<B>UnixLabels.stat</B>
|
|
|
|
,
|
|
<B>UnixLabels.lstat</B>
|
|
|
|
and
|
|
<B>UnixLabels.fstat</B>
|
|
|
|
(for obtaining information on files). These alternate functions represent
|
|
positions and sizes by 64-bit integers (type
|
|
<B>int64</B>
|
|
|
|
) instead of
|
|
regular integers (type
|
|
<B>int</B>
|
|
|
|
), thus allowing operating on files
|
|
whose sizes are greater than
|
|
<B>max_int</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAM"> </A>
|
|
<H3>Mapping files into memory</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<P>
|
|
<I>val map_file </I>
|
|
|
|
:
|
|
<B>file_descr -></B>
|
|
|
|
<B>?pos:int64 -></B>
|
|
|
|
<B>kind:('a, 'b) Bigarray.kind -></B>
|
|
|
|
<B>layout:'c Bigarray.layout -></B>
|
|
|
|
<B>shared:bool -> dims:int array -> ('a, 'b, 'c) Bigarray.Genarray.t</B>
|
|
|
|
<P>
|
|
Memory mapping of a file as a Bigarray.
|
|
<B>map_file fd kind layout shared dims</B>
|
|
|
|
returns a Bigarray of kind
|
|
<B>kind</B>
|
|
|
|
, layout
|
|
<B>layout</B>
|
|
|
|
,
|
|
and dimensions as specified in
|
|
<B>dims</B>
|
|
|
|
. The data contained in
|
|
this Bigarray are the contents of the file referred to by
|
|
the file descriptor
|
|
<B>fd</B>
|
|
|
|
(as opened previously with
|
|
<B>Unix.openfile</B>
|
|
|
|
, for example). The optional
|
|
<B>pos</B>
|
|
|
|
parameter
|
|
is the byte offset in the file of the data being mapped;
|
|
it defaults to 0 (map from the beginning of the file).
|
|
<P>
|
|
If
|
|
<B>shared</B>
|
|
|
|
is
|
|
<B>true</B>
|
|
|
|
, all modifications performed on the array
|
|
are reflected in the file. This requires that
|
|
<B>fd</B>
|
|
|
|
be opened
|
|
with write permissions. If
|
|
<B>shared</B>
|
|
|
|
is
|
|
<B>false</B>
|
|
|
|
, modifications
|
|
performed on the array are done in memory only, using
|
|
copy-on-write of the modified pages; the underlying file is not
|
|
affected.
|
|
<P>
|
|
<P>
|
|
<B>Genarray.map_file</B>
|
|
|
|
is much more efficient than reading
|
|
the whole file in a Bigarray, modifying that Bigarray,
|
|
and writing it afterwards.
|
|
<P>
|
|
To adjust automatically the dimensions of the Bigarray to
|
|
the actual size of the file, the major dimension (that is,
|
|
the first dimension for an array with C layout, and the last
|
|
dimension for an array with Fortran layout) can be given as
|
|
<B>-1</B>
|
|
|
|
.
|
|
<B>Genarray.map_file</B>
|
|
|
|
then determines the major dimension
|
|
from the size of the file. The file must contain an integral
|
|
number of sub-arrays as determined by the non-major dimensions,
|
|
otherwise
|
|
<B>Failure</B>
|
|
|
|
is raised.
|
|
<P>
|
|
If all dimensions of the Bigarray are given, the file size is
|
|
matched against the size of the Bigarray. If the file is larger
|
|
than the Bigarray, only the initial portion of the file is
|
|
mapped to the Bigarray. If the file is smaller than the big
|
|
array, the file is automatically grown to the size of the Bigarray.
|
|
This requires write permissions on
|
|
<B>fd</B>
|
|
|
|
.
|
|
<P>
|
|
Array accesses are bounds-checked, but the bounds are determined by
|
|
the initial call to
|
|
<B>map_file</B>
|
|
|
|
. Therefore, you should make sure no
|
|
other process modifies the mapped file while you're accessing it,
|
|
or a SIGBUS signal may be raised. This happens, for instance, if the
|
|
file is shrunk.
|
|
<P>
|
|
<P>
|
|
<B>Invalid_argument</B>
|
|
|
|
or
|
|
<B>Failure</B>
|
|
|
|
may be raised in cases where argument
|
|
validation fails.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.06.0
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAN"> </A>
|
|
<H3>Operations on file names</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<P>
|
|
<I>val unlink </I>
|
|
|
|
:
|
|
<B>string -> unit</B>
|
|
|
|
<P>
|
|
Removes the named file
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val rename </I>
|
|
|
|
:
|
|
<B>src:string -> dst:string -> unit</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>rename old new</B>
|
|
|
|
changes the name of a file from
|
|
<B>old</B>
|
|
|
|
to
|
|
<B>new</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val link </I>
|
|
|
|
:
|
|
<B>?follow:bool -> src:string -> dst:string -> unit</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>link ?follow source dest</B>
|
|
|
|
creates a hard link named
|
|
<B>dest</B>
|
|
|
|
to the file
|
|
named
|
|
<B>source</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<B>Raises ENOSYS</B>
|
|
|
|
On Unix if
|
|
<B>~follow:_</B>
|
|
|
|
is requested, but linkat is
|
|
unavailable.
|
|
<P>
|
|
<P>
|
|
<B>Raises ENOSYS</B>
|
|
|
|
On Windows if
|
|
<B>~follow:false</B>
|
|
|
|
is requested.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAO"> </A>
|
|
<H3>File permissions and ownership</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<I>type access_permission </I>
|
|
|
|
=
|
|
<B>Unix.access_permission</B>
|
|
|
|
=
|
|
<BR> | R_OK (* Read permission
|
|
<BR> *)
|
|
<BR> | W_OK (* Write permission
|
|
<BR> *)
|
|
<BR> | X_OK (* Execution permission
|
|
<BR> *)
|
|
<BR> | F_OK (* File exists
|
|
<BR> *)
|
|
<BR>
|
|
<P>
|
|
Flags for the
|
|
<B>UnixLabels.access</B>
|
|
|
|
call.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val chmod </I>
|
|
|
|
:
|
|
<B>string -> perm:file_perm -> unit</B>
|
|
|
|
<P>
|
|
Change the permissions of the named file.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val fchmod </I>
|
|
|
|
:
|
|
<B>file_descr -> perm:file_perm -> unit</B>
|
|
|
|
<P>
|
|
Change the permissions of an opened file.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val chown </I>
|
|
|
|
:
|
|
<B>string -> uid:int -> gid:int -> unit</B>
|
|
|
|
<P>
|
|
Change the owner uid and owner gid of the named file.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val fchown </I>
|
|
|
|
:
|
|
<B>file_descr -> uid:int -> gid:int -> unit</B>
|
|
|
|
<P>
|
|
Change the owner uid and owner gid of an opened file.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val umask </I>
|
|
|
|
:
|
|
<B>int -> int</B>
|
|
|
|
<P>
|
|
Set the process's file mode creation mask, and return the previous
|
|
mask.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val access </I>
|
|
|
|
:
|
|
<B>string -> perm:access_permission list -> unit</B>
|
|
|
|
<P>
|
|
Check that the process has the given permissions over the named
|
|
file. Raise
|
|
<B>Unix_error</B>
|
|
|
|
otherwise.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAP"> </A>
|
|
<H3>Operations on file descriptors</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<P>
|
|
<I>val dup </I>
|
|
|
|
:
|
|
<B>?cloexec:bool -> file_descr -> file_descr</B>
|
|
|
|
<P>
|
|
Return a new file descriptor referencing the same file as
|
|
the given descriptor.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val dup2 </I>
|
|
|
|
:
|
|
<B>?cloexec:bool -></B>
|
|
|
|
<B>src:file_descr -> dst:file_descr -> unit</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>dup2 fd1 fd2</B>
|
|
|
|
duplicates
|
|
<B>fd1</B>
|
|
|
|
to
|
|
<B>fd2</B>
|
|
|
|
, closing
|
|
<B>fd2</B>
|
|
|
|
if already
|
|
opened.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val set_nonblock </I>
|
|
|
|
:
|
|
<B>file_descr -> unit</B>
|
|
|
|
<P>
|
|
Set the ``non-blocking'' flag on the given descriptor.
|
|
When the non-blocking flag is set, reading on a descriptor
|
|
on which there is temporarily no data available raises the
|
|
<B>EAGAIN</B>
|
|
|
|
or
|
|
<B>EWOULDBLOCK</B>
|
|
|
|
error instead of blocking;
|
|
writing on a descriptor on which there is temporarily no room
|
|
for writing also raises
|
|
<B>EAGAIN</B>
|
|
|
|
or
|
|
<B>EWOULDBLOCK</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val clear_nonblock </I>
|
|
|
|
:
|
|
<B>file_descr -> unit</B>
|
|
|
|
<P>
|
|
Clear the ``non-blocking'' flag on the given descriptor.
|
|
See
|
|
<B>UnixLabels.set_nonblock</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val set_close_on_exec </I>
|
|
|
|
:
|
|
<B>file_descr -> unit</B>
|
|
|
|
<P>
|
|
Set the ``close-on-exec'' flag on the given descriptor.
|
|
A descriptor with the close-on-exec flag is automatically
|
|
closed when the current process starts another program with
|
|
one of the
|
|
<B>exec</B>
|
|
|
|
functions.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val clear_close_on_exec </I>
|
|
|
|
:
|
|
<B>file_descr -> unit</B>
|
|
|
|
<P>
|
|
Clear the ``close-on-exec'' flag on the given descriptor.
|
|
See
|
|
<B>UnixLabels.set_close_on_exec</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAQ"> </A>
|
|
<H3>Directories</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<P>
|
|
<I>val mkdir </I>
|
|
|
|
:
|
|
<B>string -> perm:file_perm -> unit</B>
|
|
|
|
<P>
|
|
Create a directory with the given permissions.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val rmdir </I>
|
|
|
|
:
|
|
<B>string -> unit</B>
|
|
|
|
<P>
|
|
Remove an empty directory.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val chdir </I>
|
|
|
|
:
|
|
<B>string -> unit</B>
|
|
|
|
<P>
|
|
Change the process working directory.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getcwd </I>
|
|
|
|
:
|
|
<B>unit -> string</B>
|
|
|
|
<P>
|
|
Return the name of the current working directory.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val chroot </I>
|
|
|
|
:
|
|
<B>string -> unit</B>
|
|
|
|
<P>
|
|
Change the process root directory.
|
|
<P>
|
|
<P>
|
|
<I>type dir_handle </I>
|
|
|
|
=
|
|
<B>Unix.dir_handle</B>
|
|
|
|
<P>
|
|
<P>
|
|
The type of descriptors over opened directories.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val opendir </I>
|
|
|
|
:
|
|
<B>string -> dir_handle</B>
|
|
|
|
<P>
|
|
Open a descriptor on a directory
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val readdir </I>
|
|
|
|
:
|
|
<B>dir_handle -> string</B>
|
|
|
|
<P>
|
|
Return the next entry in a directory.
|
|
<P>
|
|
<P>
|
|
<B>Raises End_of_file</B>
|
|
|
|
when the end of the directory has been reached.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val rewinddir </I>
|
|
|
|
:
|
|
<B>dir_handle -> unit</B>
|
|
|
|
<P>
|
|
Reposition the descriptor to the beginning of the directory
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val closedir </I>
|
|
|
|
:
|
|
<B>dir_handle -> unit</B>
|
|
|
|
<P>
|
|
Close a directory descriptor.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAR"> </A>
|
|
<H3>Pipes and redirections</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<P>
|
|
<I>val pipe </I>
|
|
|
|
:
|
|
<B>?cloexec:bool -> unit -> file_descr * file_descr</B>
|
|
|
|
<P>
|
|
Create a pipe. The first component of the result is opened
|
|
for reading, that's the exit to the pipe. The second component is
|
|
opened for writing, that's the entrance to the pipe.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val mkfifo </I>
|
|
|
|
:
|
|
<B>string -> perm:file_perm -> unit</B>
|
|
|
|
<P>
|
|
Create a named pipe with the given permissions.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAS"> </A>
|
|
<H3>High-level process and redirection management</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<P>
|
|
<I>val create_process </I>
|
|
|
|
:
|
|
<B>prog:string -></B>
|
|
|
|
<B>args:string array -></B>
|
|
|
|
<B>stdin:file_descr -></B>
|
|
|
|
<B>stdout:file_descr -> stderr:file_descr -> int</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>create_process prog args new_stdin new_stdout new_stderr</B>
|
|
|
|
forks a new process that executes the program
|
|
in file
|
|
<B>prog</B>
|
|
|
|
, with arguments
|
|
<B>args</B>
|
|
|
|
. The pid of the new
|
|
process is returned immediately; the new process executes
|
|
concurrently with the current process.
|
|
The standard input and outputs of the new process are connected
|
|
to the descriptors
|
|
<B>new_stdin</B>
|
|
|
|
,
|
|
<B>new_stdout</B>
|
|
|
|
and
|
|
<B>new_stderr</B>
|
|
|
|
.
|
|
Passing e.g.
|
|
<B>stdout</B>
|
|
|
|
for
|
|
<B>new_stdout</B>
|
|
|
|
prevents the redirection
|
|
and causes the new process to have the same standard output
|
|
as the current process.
|
|
The executable file
|
|
<B>prog</B>
|
|
|
|
is searched in the path.
|
|
The new process has the same environment as the current process.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val create_process_env </I>
|
|
|
|
:
|
|
<B>prog:string -></B>
|
|
|
|
<B>args:string array -></B>
|
|
|
|
<B>env:string array -></B>
|
|
|
|
<B>stdin:file_descr -></B>
|
|
|
|
<B>stdout:file_descr -> stderr:file_descr -> int</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>create_process_env prog args env new_stdin new_stdout new_stderr</B>
|
|
|
|
works as
|
|
<B>UnixLabels.create_process</B>
|
|
|
|
, except that the extra argument
|
|
<B>env</B>
|
|
|
|
specifies the environment passed to the program.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val open_process_in </I>
|
|
|
|
:
|
|
<B>string -> in_channel</B>
|
|
|
|
<P>
|
|
High-level pipe and process management. This function
|
|
runs the given command in parallel with the program.
|
|
The standard output of the command is redirected to a pipe,
|
|
which can be read via the returned input channel.
|
|
The command is interpreted by the shell
|
|
<B>/bin/sh</B>
|
|
|
|
(cf.
|
|
<B>system</B>
|
|
|
|
).
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val open_process_out </I>
|
|
|
|
:
|
|
<B>string -> out_channel</B>
|
|
|
|
<P>
|
|
Same as
|
|
<B>UnixLabels.open_process_in</B>
|
|
|
|
, but redirect the standard input of
|
|
the command to a pipe. Data written to the returned output channel
|
|
is sent to the standard input of the command.
|
|
Warning: writes on output channels are buffered, hence be careful
|
|
to call
|
|
<B>flush</B>
|
|
|
|
at the right times to ensure
|
|
correct synchronization.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val open_process </I>
|
|
|
|
:
|
|
<B>string -> in_channel * out_channel</B>
|
|
|
|
<P>
|
|
Same as
|
|
<B>UnixLabels.open_process_out</B>
|
|
|
|
, but redirects both the standard
|
|
input and standard output of the command to pipes connected to the two
|
|
returned channels. The input channel is connected to the output
|
|
of the command, and the output channel to the input of the command.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val open_process_full </I>
|
|
|
|
:
|
|
<B>string -></B>
|
|
|
|
<B>env:string array -></B>
|
|
|
|
<B>in_channel * out_channel * in_channel</B>
|
|
|
|
<P>
|
|
Similar to
|
|
<B>UnixLabels.open_process</B>
|
|
|
|
, but the second argument specifies
|
|
the environment passed to the command. The result is a triple
|
|
of channels connected respectively to the standard output, standard input,
|
|
and standard error of the command.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val open_process_args_in </I>
|
|
|
|
:
|
|
<B>string -> string array -> in_channel</B>
|
|
|
|
<P>
|
|
High-level pipe and process management. The first argument specifies the
|
|
command to run, and the second argument specifies the argument array passed
|
|
to the command. This function runs the command in parallel with the program.
|
|
The standard output of the command is redirected to a pipe, which can be read
|
|
via the returned input channel.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.08.0
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val open_process_args_out </I>
|
|
|
|
:
|
|
<B>string -> string array -> out_channel</B>
|
|
|
|
<P>
|
|
Same as
|
|
<B>Unix.open_process_args_in</B>
|
|
|
|
, but redirect the standard input of the
|
|
command to a pipe. Data written to the returned output channel is sent to
|
|
the standard input of the command. Warning: writes on output channels are
|
|
buffered, hence be careful to call
|
|
<B>flush</B>
|
|
|
|
at the right times to
|
|
ensure correct synchronization.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.08.0
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val open_process_args </I>
|
|
|
|
:
|
|
<B>string -> string array -> in_channel * out_channel</B>
|
|
|
|
<P>
|
|
Same as
|
|
<B>Unix.open_process_args_out</B>
|
|
|
|
, but redirects both the standard input
|
|
and standard output of the command to pipes connected to the two returned
|
|
channels. The input channel is connected to the output of the command, and
|
|
the output channel to the input of the command.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.08.0
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val open_process_args_full </I>
|
|
|
|
:
|
|
<B>string -></B>
|
|
|
|
<B>string array -></B>
|
|
|
|
<B>string array -> in_channel * out_channel * in_channel</B>
|
|
|
|
<P>
|
|
Similar to
|
|
<B>Unix.open_process_args</B>
|
|
|
|
, but the third argument specifies the
|
|
environment passed to the command. The result is a triple of channels
|
|
connected respectively to the standard output, standard input, and standard
|
|
error of the command.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.08.0
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val close_process_in </I>
|
|
|
|
:
|
|
<B>in_channel -> process_status</B>
|
|
|
|
<P>
|
|
Close channels opened by
|
|
<B>UnixLabels.open_process_in</B>
|
|
|
|
,
|
|
wait for the associated command to terminate,
|
|
and return its termination status.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val close_process_out </I>
|
|
|
|
:
|
|
<B>out_channel -> process_status</B>
|
|
|
|
<P>
|
|
Close channels opened by
|
|
<B>UnixLabels.open_process_out</B>
|
|
|
|
,
|
|
wait for the associated command to terminate,
|
|
and return its termination status.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val close_process </I>
|
|
|
|
:
|
|
<B>in_channel * out_channel -> process_status</B>
|
|
|
|
<P>
|
|
Close channels opened by
|
|
<B>UnixLabels.open_process</B>
|
|
|
|
,
|
|
wait for the associated command to terminate,
|
|
and return its termination status.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val close_process_full </I>
|
|
|
|
:
|
|
<B>in_channel * out_channel * in_channel -></B>
|
|
|
|
<B>process_status</B>
|
|
|
|
<P>
|
|
Close channels opened by
|
|
<B>UnixLabels.open_process_full</B>
|
|
|
|
,
|
|
wait for the associated command to terminate,
|
|
and return its termination status.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAT"> </A>
|
|
<H3>Symbolic links</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<P>
|
|
<I>val symlink </I>
|
|
|
|
:
|
|
<B>?to_dir:bool -> src:string -> dst:string -> unit</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>symlink source dest</B>
|
|
|
|
creates the file
|
|
<B>dest</B>
|
|
|
|
as a symbolic link
|
|
to the file
|
|
<B>source</B>
|
|
|
|
. See
|
|
<B>Unix.symlink</B>
|
|
|
|
for details of
|
|
<B>~to_dir</B>
|
|
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val has_symlink </I>
|
|
|
|
:
|
|
<B>unit -> bool</B>
|
|
|
|
<P>
|
|
Returns
|
|
<B>true</B>
|
|
|
|
if the user is able to create symbolic links. On Windows,
|
|
this indicates that the user not only has the SeCreateSymbolicLinkPrivilege
|
|
but is also running elevated, if necessary. On other platforms, this is
|
|
simply indicates that the symlink system call is available.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.03.0
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val readlink </I>
|
|
|
|
:
|
|
<B>string -> string</B>
|
|
|
|
<P>
|
|
Read the contents of a link.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAU"> </A>
|
|
<H3>Polling</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<P>
|
|
<I>val select </I>
|
|
|
|
:
|
|
<B>read:file_descr list -></B>
|
|
|
|
<B>write:file_descr list -></B>
|
|
|
|
<B>except:file_descr list -></B>
|
|
|
|
<B>timeout:float -></B>
|
|
|
|
<B>file_descr list * file_descr list *</B>
|
|
|
|
<B>file_descr list</B>
|
|
|
|
<P>
|
|
Wait until some input/output operations become possible on
|
|
some channels. The three list arguments are, respectively, a set
|
|
of descriptors to check for reading (first argument), for writing
|
|
(second argument), or for exceptional conditions (third argument).
|
|
The fourth argument is the maximal timeout, in seconds; a
|
|
negative fourth argument means no timeout (unbounded wait).
|
|
The result is composed of three sets of descriptors: those ready
|
|
for reading (first component), ready for writing (second component),
|
|
and over which an exceptional condition is pending (third
|
|
component).
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAV"> </A>
|
|
<H3>Locking</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<I>type lock_command </I>
|
|
|
|
=
|
|
<B>Unix.lock_command</B>
|
|
|
|
=
|
|
<BR> | F_ULOCK (* Unlock a region
|
|
<BR> *)
|
|
<BR> | F_LOCK (* Lock a region for writing, and block if already locked
|
|
<BR> *)
|
|
<BR> | F_TLOCK (* Lock a region for writing, or fail if already locked
|
|
<BR> *)
|
|
<BR> | F_TEST (* Test a region for other process locks
|
|
<BR> *)
|
|
<BR> | F_RLOCK (* Lock a region for reading, and block if already locked
|
|
<BR> *)
|
|
<BR> | F_TRLOCK (* Lock a region for reading, or fail if already locked
|
|
<BR> *)
|
|
<BR>
|
|
<P>
|
|
Commands for
|
|
<B>UnixLabels.lockf</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val lockf </I>
|
|
|
|
:
|
|
<B>file_descr -> mode:lock_command -> len:int -> unit</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>lockf fd cmd size</B>
|
|
|
|
puts a lock on a region of the file opened
|
|
as
|
|
<B>fd</B>
|
|
|
|
. The region starts at the current read/write position for
|
|
<B>fd</B>
|
|
|
|
(as set by
|
|
<B>UnixLabels.lseek</B>
|
|
|
|
), and extends
|
|
<B>size</B>
|
|
|
|
bytes forward if
|
|
<B>size</B>
|
|
|
|
is positive,
|
|
<B>size</B>
|
|
|
|
bytes backwards if
|
|
<B>size</B>
|
|
|
|
is negative,
|
|
or to the end of the file if
|
|
<B>size</B>
|
|
|
|
is zero.
|
|
A write lock prevents any other
|
|
process from acquiring a read or write lock on the region.
|
|
A read lock prevents any other
|
|
process from acquiring a write lock on the region, but lets
|
|
other processes acquire read locks on it.
|
|
<P>
|
|
The
|
|
<B>F_LOCK</B>
|
|
|
|
and
|
|
<B>F_TLOCK</B>
|
|
|
|
commands attempts to put a write lock
|
|
on the specified region.
|
|
The
|
|
<B>F_RLOCK</B>
|
|
|
|
and
|
|
<B>F_TRLOCK</B>
|
|
|
|
commands attempts to put a read lock
|
|
on the specified region.
|
|
If one or several locks put by another process prevent the current process
|
|
from acquiring the lock,
|
|
<B>F_LOCK</B>
|
|
|
|
and
|
|
<B>F_RLOCK</B>
|
|
|
|
block until these locks
|
|
are removed, while
|
|
<B>F_TLOCK</B>
|
|
|
|
and
|
|
<B>F_TRLOCK</B>
|
|
|
|
fail immediately with an
|
|
exception.
|
|
The
|
|
<B>F_ULOCK</B>
|
|
|
|
removes whatever locks the current process has on
|
|
the specified region.
|
|
Finally, the
|
|
<B>F_TEST</B>
|
|
|
|
command tests whether a write lock can be
|
|
acquired on the specified region, without actually putting a lock.
|
|
It returns immediately if successful, or fails otherwise.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAW"> </A>
|
|
<H3>Signals</H3>
|
|
|
|
Note: installation of signal handlers is performed via
|
|
the functions
|
|
<B>Sys.signal</B>
|
|
|
|
and
|
|
<B>Sys.set_signal</B>
|
|
|
|
.
|
|
<P>
|
|
|
|
<P>
|
|
<I>val kill </I>
|
|
|
|
:
|
|
<B>pid:int -> signal:int -> unit</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>kill pid sig</B>
|
|
|
|
sends signal number
|
|
<B>sig</B>
|
|
|
|
to the process
|
|
with id
|
|
<B>pid</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<I>type sigprocmask_command </I>
|
|
|
|
=
|
|
<B>Unix.sigprocmask_command</B>
|
|
|
|
=
|
|
<BR> | SIG_SETMASK
|
|
<BR> | SIG_BLOCK
|
|
<BR> | SIG_UNBLOCK
|
|
<BR>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigprocmask </I>
|
|
|
|
:
|
|
<B>mode:sigprocmask_command -> int list -> int list</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>sigprocmask cmd sigs</B>
|
|
|
|
changes the set of blocked signals.
|
|
If
|
|
<B>cmd</B>
|
|
|
|
is
|
|
<B>SIG_SETMASK</B>
|
|
|
|
, blocked signals are set to those in
|
|
the list
|
|
<B>sigs</B>
|
|
|
|
.
|
|
If
|
|
<B>cmd</B>
|
|
|
|
is
|
|
<B>SIG_BLOCK</B>
|
|
|
|
, the signals in
|
|
<B>sigs</B>
|
|
|
|
are added to
|
|
the set of blocked signals.
|
|
If
|
|
<B>cmd</B>
|
|
|
|
is
|
|
<B>SIG_UNBLOCK</B>
|
|
|
|
, the signals in
|
|
<B>sigs</B>
|
|
|
|
are removed
|
|
from the set of blocked signals.
|
|
<B>sigprocmask</B>
|
|
|
|
returns the set of previously blocked signals.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigpending </I>
|
|
|
|
:
|
|
<B>unit -> int list</B>
|
|
|
|
<P>
|
|
Return the set of blocked signals that are currently pending.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sigsuspend </I>
|
|
|
|
:
|
|
<B>int list -> unit</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>sigsuspend sigs</B>
|
|
|
|
atomically sets the blocked signals to
|
|
<B>sigs</B>
|
|
|
|
and waits for a non-ignored, non-blocked signal to be delivered.
|
|
On return, the blocked signals are reset to their initial value.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val pause </I>
|
|
|
|
:
|
|
<B>unit -> unit</B>
|
|
|
|
<P>
|
|
Wait until a non-ignored, non-blocked signal is delivered.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAX"> </A>
|
|
<H3>Time functions</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<I>type process_times </I>
|
|
|
|
=
|
|
<B>Unix.process_times</B>
|
|
|
|
= {
|
|
<BR> tms_utime :
|
|
<B>float</B>
|
|
|
|
; (* User time for the process
|
|
<BR> *)
|
|
<BR> tms_stime :
|
|
<B>float</B>
|
|
|
|
; (* System time for the process
|
|
<BR> *)
|
|
<BR> tms_cutime :
|
|
<B>float</B>
|
|
|
|
; (* User time for the children processes
|
|
<BR> *)
|
|
<BR> tms_cstime :
|
|
<B>float</B>
|
|
|
|
; (* System time for the children processes
|
|
<BR> *)
|
|
<BR> }
|
|
<P>
|
|
<P>
|
|
The execution times (CPU times) of a process.
|
|
<P>
|
|
<P>
|
|
<I>type tm </I>
|
|
|
|
=
|
|
<B>Unix.tm</B>
|
|
|
|
= {
|
|
<BR> tm_sec :
|
|
<B>int</B>
|
|
|
|
; (* Seconds 0..60
|
|
<BR> *)
|
|
<BR> tm_min :
|
|
<B>int</B>
|
|
|
|
; (* Minutes 0..59
|
|
<BR> *)
|
|
<BR> tm_hour :
|
|
<B>int</B>
|
|
|
|
; (* Hours 0..23
|
|
<BR> *)
|
|
<BR> tm_mday :
|
|
<B>int</B>
|
|
|
|
; (* Day of month 1..31
|
|
<BR> *)
|
|
<BR> tm_mon :
|
|
<B>int</B>
|
|
|
|
; (* Month of year 0..11
|
|
<BR> *)
|
|
<BR> tm_year :
|
|
<B>int</B>
|
|
|
|
; (* Year - 1900
|
|
<BR> *)
|
|
<BR> tm_wday :
|
|
<B>int</B>
|
|
|
|
; (* Day of week (Sunday is 0)
|
|
<BR> *)
|
|
<BR> tm_yday :
|
|
<B>int</B>
|
|
|
|
; (* Day of year 0..365
|
|
<BR> *)
|
|
<BR> tm_isdst :
|
|
<B>bool</B>
|
|
|
|
; (* Daylight time savings in effect
|
|
<BR> *)
|
|
<BR> }
|
|
<P>
|
|
<P>
|
|
The type representing wallclock time and calendar date.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val time </I>
|
|
|
|
:
|
|
<B>unit -> float</B>
|
|
|
|
<P>
|
|
Return the current time since 00:00:00 GMT, Jan. 1, 1970,
|
|
in seconds.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val gettimeofday </I>
|
|
|
|
:
|
|
<B>unit -> float</B>
|
|
|
|
<P>
|
|
Same as
|
|
<B>UnixLabels.time</B>
|
|
|
|
, but with resolution better than 1 second.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val gmtime </I>
|
|
|
|
:
|
|
<B>float -> tm</B>
|
|
|
|
<P>
|
|
Convert a time in seconds, as returned by
|
|
<B>UnixLabels.time</B>
|
|
|
|
, into a date
|
|
and a time. Assumes UTC (Coordinated Universal Time), also known as GMT.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val localtime </I>
|
|
|
|
:
|
|
<B>float -> tm</B>
|
|
|
|
<P>
|
|
Convert a time in seconds, as returned by
|
|
<B>UnixLabels.time</B>
|
|
|
|
, into a date
|
|
and a time. Assumes the local time zone.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val mktime </I>
|
|
|
|
:
|
|
<B>tm -> float * tm</B>
|
|
|
|
<P>
|
|
Convert a date and time, specified by the
|
|
<B>tm</B>
|
|
|
|
argument, into
|
|
a time in seconds, as returned by
|
|
<B>UnixLabels.time</B>
|
|
|
|
. The
|
|
<B>tm_isdst</B>
|
|
|
|
,
|
|
<B>tm_wday</B>
|
|
|
|
and
|
|
<B>tm_yday</B>
|
|
|
|
fields of
|
|
<B>tm</B>
|
|
|
|
are ignored. Also return a
|
|
normalized copy of the given
|
|
<B>tm</B>
|
|
|
|
record, with the
|
|
<B>tm_wday</B>
|
|
|
|
,
|
|
<B>tm_yday</B>
|
|
|
|
, and
|
|
<B>tm_isdst</B>
|
|
|
|
fields recomputed from the other fields,
|
|
and the other fields normalized (so that, e.g., 40 October is
|
|
changed into 9 November). The
|
|
<B>tm</B>
|
|
|
|
argument is interpreted in the
|
|
local time zone.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val alarm </I>
|
|
|
|
:
|
|
<B>int -> int</B>
|
|
|
|
<P>
|
|
Schedule a
|
|
<B>SIGALRM</B>
|
|
|
|
signal after the given number of seconds.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sleep </I>
|
|
|
|
:
|
|
<B>int -> unit</B>
|
|
|
|
<P>
|
|
Stop execution for the given number of seconds.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val times </I>
|
|
|
|
:
|
|
<B>unit -> process_times</B>
|
|
|
|
<P>
|
|
Return the execution times of the process.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val utimes </I>
|
|
|
|
:
|
|
<B>string -> access:float -> modif:float -> unit</B>
|
|
|
|
<P>
|
|
Set the last access time (second arg) and last modification time
|
|
(third arg) for a file. Times are expressed in seconds from
|
|
00:00:00 GMT, Jan. 1, 1970. A time of
|
|
<B>0.0</B>
|
|
|
|
is interpreted as the
|
|
current time.
|
|
<P>
|
|
<P>
|
|
<I>type interval_timer </I>
|
|
|
|
=
|
|
<B>Unix.interval_timer</B>
|
|
|
|
=
|
|
<BR> | ITIMER_REAL (* decrements in real time, and sends the signal
|
|
<B>SIGALRM</B>
|
|
|
|
when
|
|
expired.
|
|
<BR> *)
|
|
<BR> | ITIMER_VIRTUAL (* decrements in process virtual time, and sends
|
|
<B>SIGVTALRM</B>
|
|
|
|
when
|
|
expired.
|
|
<BR> *)
|
|
<BR> | ITIMER_PROF (* (for profiling) decrements both when the process
|
|
is running and when the system is running on behalf of the
|
|
process; it sends
|
|
<B>SIGPROF</B>
|
|
|
|
when expired.
|
|
<BR> *)
|
|
<BR>
|
|
<P>
|
|
The three kinds of interval timers.
|
|
<P>
|
|
<P>
|
|
<I>type interval_timer_status </I>
|
|
|
|
=
|
|
<B>Unix.interval_timer_status</B>
|
|
|
|
= {
|
|
<BR> it_interval :
|
|
<B>float</B>
|
|
|
|
; (* Period
|
|
<BR> *)
|
|
<BR> it_value :
|
|
<B>float</B>
|
|
|
|
; (* Current value of the timer
|
|
<BR> *)
|
|
<BR> }
|
|
<P>
|
|
<P>
|
|
The type describing the status of an interval timer
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getitimer </I>
|
|
|
|
:
|
|
<B>interval_timer -> interval_timer_status</B>
|
|
|
|
<P>
|
|
Return the current status of the given interval timer.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val setitimer </I>
|
|
|
|
:
|
|
<B>interval_timer -></B>
|
|
|
|
<B>interval_timer_status -> interval_timer_status</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>setitimer t s</B>
|
|
|
|
sets the interval timer
|
|
<B>t</B>
|
|
|
|
and returns
|
|
its previous status. The
|
|
<B>s</B>
|
|
|
|
argument is interpreted as follows:
|
|
<B>s.it_value</B>
|
|
|
|
, if nonzero, is the time to the next timer expiration;
|
|
<B>s.it_interval</B>
|
|
|
|
, if nonzero, specifies a value to
|
|
be used in reloading it_value when the timer expires.
|
|
Setting
|
|
<B>s.it_value</B>
|
|
|
|
to zero disable the timer.
|
|
Setting
|
|
<B>s.it_interval</B>
|
|
|
|
to zero causes the timer to be disabled
|
|
after its next expiration.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAY"> </A>
|
|
<H3>User id, group id</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<P>
|
|
<I>val getuid </I>
|
|
|
|
:
|
|
<B>unit -> int</B>
|
|
|
|
<P>
|
|
Return the user id of the user executing the process.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val geteuid </I>
|
|
|
|
:
|
|
<B>unit -> int</B>
|
|
|
|
<P>
|
|
Return the effective user id under which the process runs.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val setuid </I>
|
|
|
|
:
|
|
<B>int -> unit</B>
|
|
|
|
<P>
|
|
Set the real user id and effective user id for the process.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getgid </I>
|
|
|
|
:
|
|
<B>unit -> int</B>
|
|
|
|
<P>
|
|
Return the group id of the user executing the process.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getegid </I>
|
|
|
|
:
|
|
<B>unit -> int</B>
|
|
|
|
<P>
|
|
Return the effective group id under which the process runs.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val setgid </I>
|
|
|
|
:
|
|
<B>int -> unit</B>
|
|
|
|
<P>
|
|
Set the real group id and effective group id for the process.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getgroups </I>
|
|
|
|
:
|
|
<B>unit -> int array</B>
|
|
|
|
<P>
|
|
Return the list of groups to which the user executing the process
|
|
belongs.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val setgroups </I>
|
|
|
|
:
|
|
<B>int array -> unit</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>setgroups groups</B>
|
|
|
|
sets the supplementary group IDs for the
|
|
calling process. Appropriate privileges are required.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val initgroups </I>
|
|
|
|
:
|
|
<B>string -> int -> unit</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>initgroups user group</B>
|
|
|
|
initializes the group access list by
|
|
reading the group database /etc/group and using all groups of
|
|
which
|
|
<B>user</B>
|
|
|
|
is a member. The additional group
|
|
<B>group</B>
|
|
|
|
is also
|
|
added to the list.
|
|
<P>
|
|
<P>
|
|
<I>type passwd_entry </I>
|
|
|
|
=
|
|
<B>Unix.passwd_entry</B>
|
|
|
|
= {
|
|
<BR> pw_name :
|
|
<B>string</B>
|
|
|
|
;
|
|
<BR> pw_passwd :
|
|
<B>string</B>
|
|
|
|
;
|
|
<BR> pw_uid :
|
|
<B>int</B>
|
|
|
|
;
|
|
<BR> pw_gid :
|
|
<B>int</B>
|
|
|
|
;
|
|
<BR> pw_gecos :
|
|
<B>string</B>
|
|
|
|
;
|
|
<BR> pw_dir :
|
|
<B>string</B>
|
|
|
|
;
|
|
<BR> pw_shell :
|
|
<B>string</B>
|
|
|
|
;
|
|
<BR> }
|
|
<P>
|
|
<P>
|
|
Structure of entries in the
|
|
<B>passwd</B>
|
|
|
|
database.
|
|
<P>
|
|
<P>
|
|
<I>type group_entry </I>
|
|
|
|
=
|
|
<B>Unix.group_entry</B>
|
|
|
|
= {
|
|
<BR> gr_name :
|
|
<B>string</B>
|
|
|
|
;
|
|
<BR> gr_passwd :
|
|
<B>string</B>
|
|
|
|
;
|
|
<BR> gr_gid :
|
|
<B>int</B>
|
|
|
|
;
|
|
<BR> gr_mem :
|
|
<B>string array</B>
|
|
|
|
;
|
|
<BR> }
|
|
<P>
|
|
<P>
|
|
Structure of entries in the
|
|
<B>groups</B>
|
|
|
|
database.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getlogin </I>
|
|
|
|
:
|
|
<B>unit -> string</B>
|
|
|
|
<P>
|
|
Return the login name of the user executing the process.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getpwnam </I>
|
|
|
|
:
|
|
<B>string -> passwd_entry</B>
|
|
|
|
<P>
|
|
Find an entry in
|
|
<B>passwd</B>
|
|
|
|
with the given name, or raise
|
|
<B>Not_found</B>
|
|
|
|
if the matching entry is not found.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getgrnam </I>
|
|
|
|
:
|
|
<B>string -> group_entry</B>
|
|
|
|
<P>
|
|
Find an entry in
|
|
<B>group</B>
|
|
|
|
with the given name, or raise
|
|
<B>Not_found</B>
|
|
|
|
if the matching entry is not found.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getpwuid </I>
|
|
|
|
:
|
|
<B>int -> passwd_entry</B>
|
|
|
|
<P>
|
|
Find an entry in
|
|
<B>passwd</B>
|
|
|
|
with the given user id, or raise
|
|
<B>Not_found</B>
|
|
|
|
if the matching entry is not found.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getgrgid </I>
|
|
|
|
:
|
|
<B>int -> group_entry</B>
|
|
|
|
<P>
|
|
Find an entry in
|
|
<B>group</B>
|
|
|
|
with the given group id, or raise
|
|
<B>Not_found</B>
|
|
|
|
if the matching entry is not found.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbAZ"> </A>
|
|
<H3>Internet addresses</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<I>type inet_addr </I>
|
|
|
|
=
|
|
<B>Unix.inet_addr</B>
|
|
|
|
<P>
|
|
<P>
|
|
The abstract type of Internet addresses.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val inet_addr_of_string </I>
|
|
|
|
:
|
|
<B>string -> inet_addr</B>
|
|
|
|
<P>
|
|
Conversion from the printable representation of an Internet
|
|
address to its internal representation. The argument string
|
|
consists of 4 numbers separated by periods (
|
|
<B>XXX.YYY.ZZZ.TTT</B>
|
|
|
|
)
|
|
for IPv4 addresses, and up to 8 numbers separated by colons
|
|
for IPv6 addresses. Raise
|
|
<B>Failure</B>
|
|
|
|
when given a string that
|
|
does not match these formats.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val string_of_inet_addr </I>
|
|
|
|
:
|
|
<B>inet_addr -> string</B>
|
|
|
|
<P>
|
|
Return the printable representation of the given Internet address.
|
|
See
|
|
<B>Unix.inet_addr_of_string</B>
|
|
|
|
for a description of the
|
|
printable representation.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val inet_addr_any </I>
|
|
|
|
:
|
|
<B>inet_addr</B>
|
|
|
|
<P>
|
|
A special IPv4 address, for use only with
|
|
<B>bind</B>
|
|
|
|
, representing
|
|
all the Internet addresses that the host machine possesses.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val inet_addr_loopback </I>
|
|
|
|
:
|
|
<B>inet_addr</B>
|
|
|
|
<P>
|
|
A special IPv4 address representing the host machine (
|
|
<B>127.0.0.1</B>
|
|
|
|
).
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val inet6_addr_any </I>
|
|
|
|
:
|
|
<B>inet_addr</B>
|
|
|
|
<P>
|
|
A special IPv6 address, for use only with
|
|
<B>bind</B>
|
|
|
|
, representing
|
|
all the Internet addresses that the host machine possesses.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val inet6_addr_loopback </I>
|
|
|
|
:
|
|
<B>inet_addr</B>
|
|
|
|
<P>
|
|
A special IPv6 address representing the host machine (
|
|
<B>::1</B>
|
|
|
|
).
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbBA"> </A>
|
|
<H3>Sockets</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<I>type socket_domain </I>
|
|
|
|
=
|
|
<B>Unix.socket_domain</B>
|
|
|
|
=
|
|
<BR> | PF_UNIX (* Unix domain
|
|
<BR> *)
|
|
<BR> | PF_INET (* Internet domain (IPv4)
|
|
<BR> *)
|
|
<BR> | PF_INET6 (* Internet domain (IPv6)
|
|
<BR> *)
|
|
<BR>
|
|
<P>
|
|
The type of socket domains. Not all platforms support
|
|
IPv6 sockets (type
|
|
<B>PF_INET6</B>
|
|
|
|
).
|
|
<P>
|
|
<P>
|
|
<I>type socket_type </I>
|
|
|
|
=
|
|
<B>Unix.socket_type</B>
|
|
|
|
=
|
|
<BR> | SOCK_STREAM (* Stream socket
|
|
<BR> *)
|
|
<BR> | SOCK_DGRAM (* Datagram socket
|
|
<BR> *)
|
|
<BR> | SOCK_RAW (* Raw socket
|
|
<BR> *)
|
|
<BR> | SOCK_SEQPACKET (* Sequenced packets socket
|
|
<BR> *)
|
|
<BR>
|
|
<P>
|
|
The type of socket kinds, specifying the semantics of
|
|
communications.
|
|
<P>
|
|
<P>
|
|
<I>type sockaddr </I>
|
|
|
|
=
|
|
<B>Unix.sockaddr</B>
|
|
|
|
=
|
|
<BR> | ADDR_UNIX
|
|
<B>of </B>
|
|
|
|
<B>string</B>
|
|
|
|
<BR> | ADDR_INET
|
|
<B>of </B>
|
|
|
|
<B>inet_addr * int</B>
|
|
|
|
<I> </I>
|
|
|
|
<BR> (* The type of socket addresses.
|
|
<B>ADDR_UNIX name</B>
|
|
|
|
is a socket
|
|
address in the Unix domain;
|
|
<B>name</B>
|
|
|
|
is a file name in the file
|
|
system.
|
|
<B>ADDR_INET(addr,port)</B>
|
|
|
|
is a socket address in the Internet
|
|
domain;
|
|
<B>addr</B>
|
|
|
|
is the Internet address of the machine, and
|
|
<B>port</B>
|
|
|
|
is the port number.
|
|
<BR> *)
|
|
<BR>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val socket </I>
|
|
|
|
:
|
|
<B>?cloexec:bool -></B>
|
|
|
|
<B>domain:socket_domain -></B>
|
|
|
|
<B>kind:socket_type -> protocol:int -> file_descr</B>
|
|
|
|
<P>
|
|
Create a new socket in the given domain, and with the
|
|
given kind. The third argument is the protocol type; 0 selects
|
|
the default protocol for that kind of sockets.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val domain_of_sockaddr </I>
|
|
|
|
:
|
|
<B>sockaddr -> socket_domain</B>
|
|
|
|
<P>
|
|
Return the socket domain adequate for the given socket address.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val socketpair </I>
|
|
|
|
:
|
|
<B>?cloexec:bool -></B>
|
|
|
|
<B>domain:socket_domain -></B>
|
|
|
|
<B>kind:socket_type -></B>
|
|
|
|
<B>protocol:int -> file_descr * file_descr</B>
|
|
|
|
<P>
|
|
Create a pair of unnamed sockets, connected together.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val accept </I>
|
|
|
|
:
|
|
<B>?cloexec:bool -></B>
|
|
|
|
<B>file_descr -> file_descr * sockaddr</B>
|
|
|
|
<P>
|
|
Accept connections on the given socket. The returned descriptor
|
|
is a socket connected to the client; the returned address is
|
|
the address of the connecting client.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val bind </I>
|
|
|
|
:
|
|
<B>file_descr -> addr:sockaddr -> unit</B>
|
|
|
|
<P>
|
|
Bind a socket to an address.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val connect </I>
|
|
|
|
:
|
|
<B>file_descr -> addr:sockaddr -> unit</B>
|
|
|
|
<P>
|
|
Connect a socket to an address.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val listen </I>
|
|
|
|
:
|
|
<B>file_descr -> max:int -> unit</B>
|
|
|
|
<P>
|
|
Set up a socket for receiving connection requests. The integer
|
|
argument is the maximal number of pending requests.
|
|
<P>
|
|
<P>
|
|
<I>type shutdown_command </I>
|
|
|
|
=
|
|
<B>Unix.shutdown_command</B>
|
|
|
|
=
|
|
<BR> | SHUTDOWN_RECEIVE (* Close for receiving
|
|
<BR> *)
|
|
<BR> | SHUTDOWN_SEND (* Close for sending
|
|
<BR> *)
|
|
<BR> | SHUTDOWN_ALL (* Close both
|
|
<BR> *)
|
|
<BR>
|
|
<P>
|
|
The type of commands for
|
|
<B>shutdown</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val shutdown </I>
|
|
|
|
:
|
|
<B>file_descr -> mode:shutdown_command -> unit</B>
|
|
|
|
<P>
|
|
Shutdown a socket connection.
|
|
<B>SHUTDOWN_SEND</B>
|
|
|
|
as second argument
|
|
causes reads on the other end of the connection to return
|
|
an end-of-file condition.
|
|
<B>SHUTDOWN_RECEIVE</B>
|
|
|
|
causes writes on the other end of the connection
|
|
to return a closed pipe condition (
|
|
<B>SIGPIPE</B>
|
|
|
|
signal).
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getsockname </I>
|
|
|
|
:
|
|
<B>file_descr -> sockaddr</B>
|
|
|
|
<P>
|
|
Return the address of the given socket.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getpeername </I>
|
|
|
|
:
|
|
<B>file_descr -> sockaddr</B>
|
|
|
|
<P>
|
|
Return the address of the host connected to the given socket.
|
|
<P>
|
|
<P>
|
|
<I>type msg_flag </I>
|
|
|
|
=
|
|
<B>Unix.msg_flag</B>
|
|
|
|
=
|
|
<BR> | MSG_OOB
|
|
<BR> | MSG_DONTROUTE
|
|
<BR> | MSG_PEEK (* The flags for
|
|
<B>UnixLabels.recv</B>
|
|
|
|
,
|
|
<B>UnixLabels.recvfrom</B>
|
|
|
|
,
|
|
<B>UnixLabels.send</B>
|
|
|
|
and
|
|
<B>UnixLabels.sendto</B>
|
|
|
|
.
|
|
<BR> *)
|
|
<BR>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val recv </I>
|
|
|
|
:
|
|
<B>file_descr -></B>
|
|
|
|
<B>buf:bytes -> pos:int -> len:int -> mode:msg_flag list -> int</B>
|
|
|
|
<P>
|
|
Receive data from a connected socket.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val recvfrom </I>
|
|
|
|
:
|
|
<B>file_descr -></B>
|
|
|
|
<B>buf:bytes -></B>
|
|
|
|
<B>pos:int -></B>
|
|
|
|
<B>len:int -> mode:msg_flag list -> int * sockaddr</B>
|
|
|
|
<P>
|
|
Receive data from an unconnected socket.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val send </I>
|
|
|
|
:
|
|
<B>file_descr -></B>
|
|
|
|
<B>buf:bytes -> pos:int -> len:int -> mode:msg_flag list -> int</B>
|
|
|
|
<P>
|
|
Send data over a connected socket.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val send_substring </I>
|
|
|
|
:
|
|
<B>file_descr -></B>
|
|
|
|
<B>buf:string -> pos:int -> len:int -> mode:msg_flag list -> int</B>
|
|
|
|
<P>
|
|
Same as
|
|
<B>send</B>
|
|
|
|
, but take the data from a string instead of a byte
|
|
sequence.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.02.0
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sendto </I>
|
|
|
|
:
|
|
<B>file_descr -></B>
|
|
|
|
<B>buf:bytes -></B>
|
|
|
|
<B>pos:int -></B>
|
|
|
|
<B>len:int -> mode:msg_flag list -> addr:sockaddr -> int</B>
|
|
|
|
<P>
|
|
Send data over an unconnected socket.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val sendto_substring </I>
|
|
|
|
:
|
|
<B>file_descr -></B>
|
|
|
|
<B>buf:string -></B>
|
|
|
|
<B>pos:int -></B>
|
|
|
|
<B>len:int -> mode:msg_flag list -> sockaddr -> int</B>
|
|
|
|
<P>
|
|
Same as
|
|
<B>sendto</B>
|
|
|
|
, but take the data from a string instead of a
|
|
byte sequence.
|
|
<P>
|
|
<P>
|
|
<B>Since</B>
|
|
|
|
4.02.0
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbBB"> </A>
|
|
<H3>Socket options</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<I>type socket_bool_option </I>
|
|
|
|
=
|
|
<BR> | SO_DEBUG (* Record debugging information
|
|
<BR> *)
|
|
<BR> | SO_BROADCAST (* Permit sending of broadcast messages
|
|
<BR> *)
|
|
<BR> | SO_REUSEADDR (* Allow reuse of local addresses for bind
|
|
<BR> *)
|
|
<BR> | SO_KEEPALIVE (* Keep connection active
|
|
<BR> *)
|
|
<BR> | SO_DONTROUTE (* Bypass the standard routing algorithms
|
|
<BR> *)
|
|
<BR> | SO_OOBINLINE (* Leave out-of-band data in line
|
|
<BR> *)
|
|
<BR> | SO_ACCEPTCONN (* Report whether socket listening is enabled
|
|
<BR> *)
|
|
<BR> | TCP_NODELAY (* Control the Nagle algorithm for TCP sockets
|
|
<BR> *)
|
|
<BR> | IPV6_ONLY (* Forbid binding an IPv6 socket to an IPv4 address
|
|
<BR> *)
|
|
<BR>
|
|
<P>
|
|
The socket options that can be consulted with
|
|
<B>UnixLabels.getsockopt</B>
|
|
|
|
and modified with
|
|
<B>UnixLabels.setsockopt</B>
|
|
|
|
. These options have a boolean
|
|
(
|
|
<B>true</B>
|
|
|
|
/
|
|
<B>false</B>
|
|
|
|
) value.
|
|
<P>
|
|
<P>
|
|
<I>type socket_int_option </I>
|
|
|
|
=
|
|
<BR> | SO_SNDBUF (* Size of send buffer
|
|
<BR> *)
|
|
<BR> | SO_RCVBUF (* Size of received buffer
|
|
<BR> *)
|
|
<BR> | SO_ERROR (* Deprecated. Use
|
|
<B>Unix.getsockopt_error</B>
|
|
|
|
instead.
|
|
<BR> *)
|
|
<BR> | SO_TYPE (* Report the socket type
|
|
<BR> *)
|
|
<BR> | SO_RCVLOWAT (* Minimum number of bytes to process for input operations
|
|
<BR> *)
|
|
<BR> | SO_SNDLOWAT (* Minimum number of bytes to process for output operations
|
|
<BR> *)
|
|
<BR>
|
|
<P>
|
|
The socket options that can be consulted with
|
|
<B>UnixLabels.getsockopt_int</B>
|
|
|
|
and modified with
|
|
<B>UnixLabels.setsockopt_int</B>
|
|
|
|
. These options have an
|
|
integer value.
|
|
<P>
|
|
<P>
|
|
<I>type socket_optint_option </I>
|
|
|
|
=
|
|
<BR> | SO_LINGER (* Whether to linger on closed connections
|
|
that have data present, and for how long
|
|
(in seconds)
|
|
<BR> *)
|
|
<BR>
|
|
<P>
|
|
The socket options that can be consulted with
|
|
<B>Unix.getsockopt_optint</B>
|
|
|
|
and modified with
|
|
<B>Unix.setsockopt_optint</B>
|
|
|
|
. These options have a
|
|
value of type
|
|
<B>int option</B>
|
|
|
|
, with
|
|
<B>None</B>
|
|
|
|
meaning ``disabled''.
|
|
<P>
|
|
<P>
|
|
<I>type socket_float_option </I>
|
|
|
|
=
|
|
<BR> | SO_RCVTIMEO (* Timeout for input operations
|
|
<BR> *)
|
|
<BR> | SO_SNDTIMEO (* Timeout for output operations
|
|
<BR> *)
|
|
<BR>
|
|
<P>
|
|
The socket options that can be consulted with
|
|
<B>UnixLabels.getsockopt_float</B>
|
|
|
|
and modified with
|
|
<B>UnixLabels.setsockopt_float</B>
|
|
|
|
. These options have a
|
|
floating-point value representing a time in seconds.
|
|
The value 0 means infinite timeout.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getsockopt </I>
|
|
|
|
:
|
|
<B>file_descr -> socket_bool_option -> bool</B>
|
|
|
|
<P>
|
|
Return the current status of a boolean-valued option
|
|
in the given socket.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val setsockopt </I>
|
|
|
|
:
|
|
<B>file_descr -> socket_bool_option -> bool -> unit</B>
|
|
|
|
<P>
|
|
Set or clear a boolean-valued option in the given socket.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getsockopt_int </I>
|
|
|
|
:
|
|
<B>file_descr -> socket_int_option -> int</B>
|
|
|
|
<P>
|
|
Same as
|
|
<B>Unix.getsockopt</B>
|
|
|
|
for an integer-valued socket option.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val setsockopt_int </I>
|
|
|
|
:
|
|
<B>file_descr -> socket_int_option -> int -> unit</B>
|
|
|
|
<P>
|
|
Same as
|
|
<B>Unix.setsockopt</B>
|
|
|
|
for an integer-valued socket option.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getsockopt_optint </I>
|
|
|
|
:
|
|
<B>file_descr -> socket_optint_option -> int option</B>
|
|
|
|
<P>
|
|
Same as
|
|
<B>Unix.getsockopt</B>
|
|
|
|
for a socket option whose value is
|
|
an
|
|
<B>int option</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val setsockopt_optint </I>
|
|
|
|
:
|
|
<B>file_descr -></B>
|
|
|
|
<B>socket_optint_option -> int option -> unit</B>
|
|
|
|
<P>
|
|
Same as
|
|
<B>Unix.setsockopt</B>
|
|
|
|
for a socket option whose value is
|
|
an
|
|
<B>int option</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getsockopt_float </I>
|
|
|
|
:
|
|
<B>file_descr -> socket_float_option -> float</B>
|
|
|
|
<P>
|
|
Same as
|
|
<B>Unix.getsockopt</B>
|
|
|
|
for a socket option whose value is a
|
|
floating-point number.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val setsockopt_float </I>
|
|
|
|
:
|
|
<B>file_descr -> socket_float_option -> float -> unit</B>
|
|
|
|
<P>
|
|
Same as
|
|
<B>Unix.setsockopt</B>
|
|
|
|
for a socket option whose value is a
|
|
floating-point number.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getsockopt_error </I>
|
|
|
|
:
|
|
<B>file_descr -> error option</B>
|
|
|
|
<P>
|
|
Return the error condition associated with the given socket,
|
|
and clear it.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbBC"> </A>
|
|
<H3>High-level network connection functions</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<P>
|
|
<I>val open_connection </I>
|
|
|
|
:
|
|
<B>sockaddr -> in_channel * out_channel</B>
|
|
|
|
<P>
|
|
Connect to a server at the given address.
|
|
Return a pair of buffered channels connected to the server.
|
|
Remember to call
|
|
<B>flush</B>
|
|
|
|
on the output channel at the right
|
|
times to ensure correct synchronization.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val shutdown_connection </I>
|
|
|
|
:
|
|
<B>in_channel -> unit</B>
|
|
|
|
<P>
|
|
``Shut down'' a connection established with
|
|
<B>UnixLabels.open_connection</B>
|
|
|
|
;
|
|
that is, transmit an end-of-file condition to the server reading
|
|
on the other side of the connection.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val establish_server </I>
|
|
|
|
:
|
|
<B>(in_channel -> out_channel -> unit) -></B>
|
|
|
|
<B>addr:sockaddr -> unit</B>
|
|
|
|
<P>
|
|
Establish a server on the given address.
|
|
The function given as first argument is called for each connection
|
|
with two buffered channels connected to the client. A new process
|
|
is created for each connection. The function
|
|
<B>UnixLabels.establish_server</B>
|
|
|
|
never returns normally.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbBD"> </A>
|
|
<H3>Host and protocol databases</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<I>type host_entry </I>
|
|
|
|
=
|
|
<B>Unix.host_entry</B>
|
|
|
|
= {
|
|
<BR> h_name :
|
|
<B>string</B>
|
|
|
|
;
|
|
<BR> h_aliases :
|
|
<B>string array</B>
|
|
|
|
;
|
|
<BR> h_addrtype :
|
|
<B>socket_domain</B>
|
|
|
|
;
|
|
<BR> h_addr_list :
|
|
<B>inet_addr array</B>
|
|
|
|
;
|
|
<BR> }
|
|
<P>
|
|
<P>
|
|
Structure of entries in the
|
|
<B>hosts</B>
|
|
|
|
database.
|
|
<P>
|
|
<P>
|
|
<I>type protocol_entry </I>
|
|
|
|
=
|
|
<B>Unix.protocol_entry</B>
|
|
|
|
= {
|
|
<BR> p_name :
|
|
<B>string</B>
|
|
|
|
;
|
|
<BR> p_aliases :
|
|
<B>string array</B>
|
|
|
|
;
|
|
<BR> p_proto :
|
|
<B>int</B>
|
|
|
|
;
|
|
<BR> }
|
|
<P>
|
|
<P>
|
|
Structure of entries in the
|
|
<B>protocols</B>
|
|
|
|
database.
|
|
<P>
|
|
<P>
|
|
<I>type service_entry </I>
|
|
|
|
=
|
|
<B>Unix.service_entry</B>
|
|
|
|
= {
|
|
<BR> s_name :
|
|
<B>string</B>
|
|
|
|
;
|
|
<BR> s_aliases :
|
|
<B>string array</B>
|
|
|
|
;
|
|
<BR> s_port :
|
|
<B>int</B>
|
|
|
|
;
|
|
<BR> s_proto :
|
|
<B>string</B>
|
|
|
|
;
|
|
<BR> }
|
|
<P>
|
|
<P>
|
|
Structure of entries in the
|
|
<B>services</B>
|
|
|
|
database.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val gethostname </I>
|
|
|
|
:
|
|
<B>unit -> string</B>
|
|
|
|
<P>
|
|
Return the name of the local host.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val gethostbyname </I>
|
|
|
|
:
|
|
<B>string -> host_entry</B>
|
|
|
|
<P>
|
|
Find an entry in
|
|
<B>hosts</B>
|
|
|
|
with the given name, or raise
|
|
<B>Not_found</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val gethostbyaddr </I>
|
|
|
|
:
|
|
<B>inet_addr -> host_entry</B>
|
|
|
|
<P>
|
|
Find an entry in
|
|
<B>hosts</B>
|
|
|
|
with the given address, or raise
|
|
<B>Not_found</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getprotobyname </I>
|
|
|
|
:
|
|
<B>string -> protocol_entry</B>
|
|
|
|
<P>
|
|
Find an entry in
|
|
<B>protocols</B>
|
|
|
|
with the given name, or raise
|
|
<B>Not_found</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getprotobynumber </I>
|
|
|
|
:
|
|
<B>int -> protocol_entry</B>
|
|
|
|
<P>
|
|
Find an entry in
|
|
<B>protocols</B>
|
|
|
|
with the given protocol number,
|
|
or raise
|
|
<B>Not_found</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getservbyname </I>
|
|
|
|
:
|
|
<B>string -> protocol:string -> service_entry</B>
|
|
|
|
<P>
|
|
Find an entry in
|
|
<B>services</B>
|
|
|
|
with the given name, or raise
|
|
<B>Not_found</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getservbyport </I>
|
|
|
|
:
|
|
<B>int -> protocol:string -> service_entry</B>
|
|
|
|
<P>
|
|
Find an entry in
|
|
<B>services</B>
|
|
|
|
with the given service number,
|
|
or raise
|
|
<B>Not_found</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<I>type addr_info </I>
|
|
|
|
= {
|
|
<BR> ai_family :
|
|
<B>socket_domain</B>
|
|
|
|
; (* Socket domain
|
|
<BR> *)
|
|
<BR> ai_socktype :
|
|
<B>socket_type</B>
|
|
|
|
; (* Socket type
|
|
<BR> *)
|
|
<BR> ai_protocol :
|
|
<B>int</B>
|
|
|
|
; (* Socket protocol number
|
|
<BR> *)
|
|
<BR> ai_addr :
|
|
<B>sockaddr</B>
|
|
|
|
; (* Address
|
|
<BR> *)
|
|
<BR> ai_canonname :
|
|
<B>string</B>
|
|
|
|
; (* Canonical host name
|
|
<BR> *)
|
|
<BR> }
|
|
<P>
|
|
<P>
|
|
Address information returned by
|
|
<B>Unix.getaddrinfo</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<I>type getaddrinfo_option </I>
|
|
|
|
=
|
|
<BR> | AI_FAMILY
|
|
<B>of </B>
|
|
|
|
<B>socket_domain</B>
|
|
|
|
<I> </I>
|
|
|
|
<BR> (* Impose the given socket domain
|
|
<BR> *)
|
|
<BR> | AI_SOCKTYPE
|
|
<B>of </B>
|
|
|
|
<B>socket_type</B>
|
|
|
|
<I> </I>
|
|
|
|
<BR> (* Impose the given socket type
|
|
<BR> *)
|
|
<BR> | AI_PROTOCOL
|
|
<B>of </B>
|
|
|
|
<B>int</B>
|
|
|
|
<I> </I>
|
|
|
|
<BR> (* Impose the given protocol
|
|
<BR> *)
|
|
<BR> | AI_NUMERICHOST (* Do not call name resolver,
|
|
expect numeric IP address
|
|
<BR> *)
|
|
<BR> | AI_CANONNAME (* Fill the
|
|
<B>ai_canonname</B>
|
|
|
|
field
|
|
of the result
|
|
<BR> *)
|
|
<BR> | AI_PASSIVE (* Set address to ``any'' address
|
|
for use with
|
|
<B>Unix.bind</B>
|
|
|
|
<P>
|
|
<BR> *)
|
|
<BR>
|
|
<P>
|
|
Options to
|
|
<B>Unix.getaddrinfo</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getaddrinfo </I>
|
|
|
|
:
|
|
<B>string -></B>
|
|
|
|
<B>string -> getaddrinfo_option list -> addr_info list</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>getaddrinfo host service opts</B>
|
|
|
|
returns a list of
|
|
<B>Unix.addr_info</B>
|
|
|
|
records describing socket parameters and addresses suitable for
|
|
communicating with the given host and service. The empty list is
|
|
returned if the host or service names are unknown, or the constraints
|
|
expressed in
|
|
<B>opts</B>
|
|
|
|
cannot be satisfied.
|
|
<P>
|
|
<P>
|
|
<B>host</B>
|
|
|
|
is either a host name or the string representation of an IP
|
|
address.
|
|
<B>host</B>
|
|
|
|
can be given as the empty string; in this case,
|
|
the ``any'' address or the ``loopback'' address are used,
|
|
depending whether
|
|
<B>opts</B>
|
|
|
|
contains
|
|
<B>AI_PASSIVE</B>
|
|
|
|
.
|
|
<B>service</B>
|
|
|
|
is either a service name or the string representation of
|
|
a port number.
|
|
<B>service</B>
|
|
|
|
can be given as the empty string;
|
|
in this case, the port field of the returned addresses is set to 0.
|
|
<B>opts</B>
|
|
|
|
is a possibly empty list of options that allows the caller
|
|
to force a particular socket domain (e.g. IPv6 only or IPv4 only)
|
|
or a particular socket type (e.g. TCP only or UDP only).
|
|
<P>
|
|
<P>
|
|
<I>type name_info </I>
|
|
|
|
= {
|
|
<BR> ni_hostname :
|
|
<B>string</B>
|
|
|
|
; (* Name or IP address of host
|
|
<BR> *)
|
|
<BR> ni_service :
|
|
<B>string</B>
|
|
|
|
; (* Name of service or port number
|
|
<BR> *)
|
|
<BR> }
|
|
<P>
|
|
<P>
|
|
Host and service information returned by
|
|
<B>Unix.getnameinfo</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<I>type getnameinfo_option </I>
|
|
|
|
=
|
|
<BR> | NI_NOFQDN (* Do not qualify local host names
|
|
<BR> *)
|
|
<BR> | NI_NUMERICHOST (* Always return host as IP address
|
|
<BR> *)
|
|
<BR> | NI_NAMEREQD (* Fail if host name cannot be determined
|
|
<BR> *)
|
|
<BR> | NI_NUMERICSERV (* Always return service as port number
|
|
<BR> *)
|
|
<BR> | NI_DGRAM (* Consider the service as UDP-based
|
|
instead of the default TCP
|
|
<BR> *)
|
|
<BR>
|
|
<P>
|
|
Options to
|
|
<B>Unix.getnameinfo</B>
|
|
|
|
.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val getnameinfo </I>
|
|
|
|
:
|
|
<B>sockaddr -></B>
|
|
|
|
<B>getnameinfo_option list -> name_info</B>
|
|
|
|
<P>
|
|
<P>
|
|
<B>getnameinfo addr opts</B>
|
|
|
|
returns the host name and service name
|
|
corresponding to the socket address
|
|
<B>addr</B>
|
|
|
|
.
|
|
<B>opts</B>
|
|
|
|
is a possibly
|
|
empty list of options that governs how these names are obtained.
|
|
Raise
|
|
<B>Not_found</B>
|
|
|
|
if an error occurs.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<A NAME="lbBE"> </A>
|
|
<H3>Terminal interface</H3>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
<P>
|
|
<P>
|
|
|
|
The following functions implement the POSIX standard terminal
|
|
interface. They provide control over asynchronous communication ports
|
|
and pseudo-terminals. Refer to the
|
|
<B>termios</B>
|
|
|
|
man page for a
|
|
complete description.
|
|
<P>
|
|
|
|
<I>type terminal_io </I>
|
|
|
|
=
|
|
<B>Unix.terminal_io</B>
|
|
|
|
= {
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_ignbrk :
|
|
<B>bool</B>
|
|
|
|
; (* Ignore the break condition.
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_brkint :
|
|
<B>bool</B>
|
|
|
|
; (* Signal interrupt on break condition.
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_ignpar :
|
|
<B>bool</B>
|
|
|
|
; (* Ignore characters with parity errors.
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_parmrk :
|
|
<B>bool</B>
|
|
|
|
; (* Mark parity errors.
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_inpck :
|
|
<B>bool</B>
|
|
|
|
; (* Enable parity check on input.
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_istrip :
|
|
<B>bool</B>
|
|
|
|
; (* Strip 8th bit on input characters.
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_inlcr :
|
|
<B>bool</B>
|
|
|
|
; (* Map NL to CR on input.
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_igncr :
|
|
<B>bool</B>
|
|
|
|
; (* Ignore CR on input.
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_icrnl :
|
|
<B>bool</B>
|
|
|
|
; (* Map CR to NL on input.
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_ixon :
|
|
<B>bool</B>
|
|
|
|
; (* Recognize XON/XOFF characters on input.
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_ixoff :
|
|
<B>bool</B>
|
|
|
|
; (* Emit XON/XOFF chars to control input flow.
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_opost :
|
|
<B>bool</B>
|
|
|
|
; (* Enable output processing.
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_obaud :
|
|
<B>int</B>
|
|
|
|
; (* Output baud rate (0 means close connection).
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_ibaud :
|
|
<B>int</B>
|
|
|
|
; (* Input baud rate.
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_csize :
|
|
<B>int</B>
|
|
|
|
; (* Number of bits per character (5-8).
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_cstopb :
|
|
<B>int</B>
|
|
|
|
; (* Number of stop bits (1-2).
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_cread :
|
|
<B>bool</B>
|
|
|
|
; (* Reception is enabled.
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_parenb :
|
|
<B>bool</B>
|
|
|
|
; (* Enable parity generation and detection.
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_parodd :
|
|
<B>bool</B>
|
|
|
|
; (* Specify odd parity instead of even.
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_hupcl :
|
|
<B>bool</B>
|
|
|
|
; (* Hang up on last close.
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_clocal :
|
|
<B>bool</B>
|
|
|
|
; (* Ignore modem status lines.
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_isig :
|
|
<B>bool</B>
|
|
|
|
; (* Generate signal on INTR, QUIT, SUSP.
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_icanon :
|
|
<B>bool</B>
|
|
|
|
; (* Enable canonical processing
|
|
(line buffering and editing)
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_noflsh :
|
|
<B>bool</B>
|
|
|
|
; (* Disable flush after INTR, QUIT, SUSP.
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_echo :
|
|
<B>bool</B>
|
|
|
|
; (* Echo input characters.
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_echoe :
|
|
<B>bool</B>
|
|
|
|
; (* Echo ERASE (to erase previous character).
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_echok :
|
|
<B>bool</B>
|
|
|
|
; (* Echo KILL (to erase the current line).
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_echonl :
|
|
<B>bool</B>
|
|
|
|
; (* Echo NL even if c_echo is not set.
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_vintr :
|
|
<B>char</B>
|
|
|
|
; (* Interrupt character (usually ctrl-C).
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_vquit :
|
|
<B>char</B>
|
|
|
|
; (* Quit character (usually ctrl-\).
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_verase :
|
|
<B>char</B>
|
|
|
|
; (* Erase character (usually DEL or ctrl-H).
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_vkill :
|
|
<B>char</B>
|
|
|
|
; (* Kill line character (usually ctrl-U).
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_veof :
|
|
<B>char</B>
|
|
|
|
; (* End-of-file character (usually ctrl-D).
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_veol :
|
|
<B>char</B>
|
|
|
|
; (* Alternate end-of-line char. (usually none).
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_vmin :
|
|
<B>int</B>
|
|
|
|
; (* Minimum number of characters to read
|
|
before the read request is satisfied.
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_vtime :
|
|
<B>int</B>
|
|
|
|
; (* Maximum read wait (in 0.1s units).
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_vstart :
|
|
<B>char</B>
|
|
|
|
; (* Start character (usually ctrl-Q).
|
|
<BR> *)
|
|
<P>
|
|
<B>mutable </B>
|
|
|
|
c_vstop :
|
|
<B>char</B>
|
|
|
|
; (* Stop character (usually ctrl-S).
|
|
<BR> *)
|
|
<BR> }
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val tcgetattr </I>
|
|
|
|
:
|
|
<B>file_descr -> terminal_io</B>
|
|
|
|
<P>
|
|
Return the status of the terminal referred to by the given
|
|
file descriptor.
|
|
<P>
|
|
<P>
|
|
<I>type setattr_when </I>
|
|
|
|
=
|
|
<B>Unix.setattr_when</B>
|
|
|
|
=
|
|
<BR> | TCSANOW
|
|
<BR> | TCSADRAIN
|
|
<BR> | TCSAFLUSH
|
|
<BR>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val tcsetattr </I>
|
|
|
|
:
|
|
<B>file_descr -></B>
|
|
|
|
<B>mode:setattr_when -> terminal_io -> unit</B>
|
|
|
|
<P>
|
|
Set the status of the terminal referred to by the given
|
|
file descriptor. The second argument indicates when the
|
|
status change takes place: immediately (
|
|
<B>TCSANOW</B>
|
|
|
|
),
|
|
when all pending output has been transmitted (
|
|
<B>TCSADRAIN</B>
|
|
|
|
),
|
|
or after flushing all input that has been received but not
|
|
read (
|
|
<B>TCSAFLUSH</B>
|
|
|
|
).
|
|
<B>TCSADRAIN</B>
|
|
|
|
is recommended when changing
|
|
the output parameters;
|
|
<B>TCSAFLUSH</B>
|
|
|
|
, when changing the input
|
|
parameters.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val tcsendbreak </I>
|
|
|
|
:
|
|
<B>file_descr -> duration:int -> unit</B>
|
|
|
|
<P>
|
|
Send a break condition on the given file descriptor.
|
|
The second argument is the duration of the break, in 0.1s units;
|
|
0 means standard duration (0.25s).
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val tcdrain </I>
|
|
|
|
:
|
|
<B>file_descr -> unit</B>
|
|
|
|
<P>
|
|
Waits until all output written on the given file descriptor
|
|
has been transmitted.
|
|
<P>
|
|
<P>
|
|
<I>type flush_queue </I>
|
|
|
|
=
|
|
<B>Unix.flush_queue</B>
|
|
|
|
=
|
|
<BR> | TCIFLUSH
|
|
<BR> | TCOFLUSH
|
|
<BR> | TCIOFLUSH
|
|
<BR>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val tcflush </I>
|
|
|
|
:
|
|
<B>file_descr -> mode:flush_queue -> unit</B>
|
|
|
|
<P>
|
|
Discard data written on the given file descriptor but not yet
|
|
transmitted, or data received but not yet read, depending on the
|
|
second argument:
|
|
<B>TCIFLUSH</B>
|
|
|
|
flushes data received but not read,
|
|
<B>TCOFLUSH</B>
|
|
|
|
flushes data written but not transmitted, and
|
|
<B>TCIOFLUSH</B>
|
|
|
|
flushes both.
|
|
<P>
|
|
<P>
|
|
<I>type flow_action </I>
|
|
|
|
=
|
|
<B>Unix.flow_action</B>
|
|
|
|
=
|
|
<BR> | TCOOFF
|
|
<BR> | TCOON
|
|
<BR> | TCIOFF
|
|
<BR> | TCION
|
|
<BR>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val tcflow </I>
|
|
|
|
:
|
|
<B>file_descr -> mode:flow_action -> unit</B>
|
|
|
|
<P>
|
|
Suspend or restart reception or transmission of data on
|
|
the given file descriptor, depending on the second argument:
|
|
<B>TCOOFF</B>
|
|
|
|
suspends output,
|
|
<B>TCOON</B>
|
|
|
|
restarts output,
|
|
<B>TCIOFF</B>
|
|
|
|
transmits a STOP character to suspend input,
|
|
and
|
|
<B>TCION</B>
|
|
|
|
transmits a START character to restart input.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
<I>val setsid </I>
|
|
|
|
:
|
|
<B>unit -> int</B>
|
|
|
|
<P>
|
|
Put the calling process in a new session and detach it from
|
|
its controlling terminal.
|
|
<P>
|
|
<P>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="2"><A HREF="#lbAC">Module</A><DD>
|
|
<DT id="3"><A HREF="#lbAD">Documentation</A><DD>
|
|
<DL>
|
|
<DT id="4"><A HREF="#lbAE">Error report</A><DD>
|
|
<DT id="5"><A HREF="#lbAF">Access to the process environment</A><DD>
|
|
<DT id="6"><A HREF="#lbAG">Process handling</A><DD>
|
|
<DT id="7"><A HREF="#lbAH">Basic file input/output</A><DD>
|
|
<DT id="8"><A HREF="#lbAI">Interfacing with the standard input/output library</A><DD>
|
|
<DT id="9"><A HREF="#lbAJ">Seeking and truncating</A><DD>
|
|
<DT id="10"><A HREF="#lbAK">File status</A><DD>
|
|
<DT id="11"><A HREF="#lbAL">File operations on large files</A><DD>
|
|
<DT id="12"><A HREF="#lbAM">Mapping files into memory</A><DD>
|
|
<DT id="13"><A HREF="#lbAN">Operations on file names</A><DD>
|
|
<DT id="14"><A HREF="#lbAO">File permissions and ownership</A><DD>
|
|
<DT id="15"><A HREF="#lbAP">Operations on file descriptors</A><DD>
|
|
<DT id="16"><A HREF="#lbAQ">Directories</A><DD>
|
|
<DT id="17"><A HREF="#lbAR">Pipes and redirections</A><DD>
|
|
<DT id="18"><A HREF="#lbAS">High-level process and redirection management</A><DD>
|
|
<DT id="19"><A HREF="#lbAT">Symbolic links</A><DD>
|
|
<DT id="20"><A HREF="#lbAU">Polling</A><DD>
|
|
<DT id="21"><A HREF="#lbAV">Locking</A><DD>
|
|
<DT id="22"><A HREF="#lbAW">Signals</A><DD>
|
|
<DT id="23"><A HREF="#lbAX">Time functions</A><DD>
|
|
<DT id="24"><A HREF="#lbAY">User id, group id</A><DD>
|
|
<DT id="25"><A HREF="#lbAZ">Internet addresses</A><DD>
|
|
<DT id="26"><A HREF="#lbBA">Sockets</A><DD>
|
|
<DT id="27"><A HREF="#lbBB">Socket options</A><DD>
|
|
<DT id="28"><A HREF="#lbBC">High-level network connection functions</A><DD>
|
|
<DT id="29"><A HREF="#lbBD">Host and protocol databases</A><DD>
|
|
<DT id="30"><A HREF="#lbBE">Terminal interface</A><DD>
|
|
</DL>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:59 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|