Legend:
Library
Module
Module type
Parameter
Class
Class type
All functions, those not available on this platform will raise Not_available with function name as an argument
ExtUnix
These functions are thin wrappers for underlying system API, consult the corresponding man pages and/or system documentation for details.
exceptionNot_availableof string
Not_available "symbol" may be raised by functions in ExtUnix.All if the wrapped C function or constant is not available on this platform.
ExtUnix.Specific includes only functions available on the current platform and will not raise Not_available. Note that libc wrappers underlying ExtUnix.Specific functions may still raise ENOSYS (Not implemented) error even though the function is available.
type of bigarray used by BA submodules that read from files into bigarrays or write bigarrays into files. The only constraint here is Bigarray.c_layout.
On Windows, statvfs root is emulated. root must be the root directory of the volume to be described. A trailing backslash is required. The f_flag and f_fsid fields are retrieved from a call to GetVolumeInformation. Filesystem flags are provided raw in f_flag, and only FILE_READ_ONLY_VOLUME is mapped to ST_RDONLY in f_flags.
fallocate fd off len allocates disk space to ensure that subsequent writes between off and off + len in fd will not fail because of lack of disk space. The file size is modified if off + len is bigger than the current size.
all_pread fd off buf ofs len reads up to len bytes from file descriptor fd at offset off (from the start of the file) into the string buf at offset ofs. The file offset is not changed.
all_pread repeats the read operation until all characters have been read or an error occurs. Returns less than the number of characters requested on EAGAIN, EWOULDBLOCK or End-of-file but only ever returns 0 on End-of-file. Continues the read operation on EINTR. Raises an Unix.Unix_error exception in all other cases.
single_pread fd off buf ifs len reads up to len bytes from file descriptor fd at offset off (from the start of the file) into the string buf at offset ofs. The file offset is not changed.
single_pread attempts to read only once. Returns the number of characters read or raises an Unix.Unix_error exception.
pread fd off buf ofs len reads up to len bytes from file descriptor fd at offset off (from the start of the file) into the string buf at offset ofs. The file offset is not changed.
pread repeats the read operation until all characters have been read or an error occurs. Raises an Unix.Unix_error exception if 0 characters could be read before an error occurs. Continues the read operation on EINTR. Returns the number of characters written in all other cases.
intr_pread fd off buf ofs len reads up to len bytes from file descriptor fd at offset off (from the start of the file) into the string buf at offset ofs. The file offset is not changed.
intr_pread repeats the read operation until all characters have been read or an error occurs. Raises an Unix.Unix_error exception if 0 characters could be read before an error occurs. Does NOT continue on EINTR. Returns the number of characters written in all other cases.
val unsafe_all_pwrite : Unix.file_descr->int ->string ->int ->int -> int
all_pwrite fd off buf ofs len writes up to len bytes from file descriptor fd at offset off (from the start of the file) into the string buf at offset ofs. The file offset is not changed.
all_pwrite repeats the write operation until all characters have been written or an error occurs. Returns less than the number of characters requested on EAGAIN, EWOULDBLOCK but never 0. Continues the write operation on EINTR. Raises an Unix.Unix_error exception in all other cases.
val all_pwrite : Unix.file_descr->int ->string ->int ->int -> int
val unsafe_single_pwrite :
Unix.file_descr->int ->string ->int ->int ->
int
single_pwrite fd off buf ofs len writes up to len bytes from file descriptor fd at offset off (from the start of the file) into the string buf at offset ofs. The file offset is not changed.
single_pwrite attempts to write only once. Returns the number of characters written or raises an Unix.Unix_error exception.
val single_pwrite : Unix.file_descr->int ->string ->int ->int -> int
val unsafe_pwrite : Unix.file_descr->int ->string ->int ->int -> int
pwrite fd off buf ofs len writes up to len bytes from file descriptor fd at offset off (from the start of the file) into the string buf at offset ofs. The file offset is not changed.
pwrite repeats the write operation until all characters have been written or an error occurs. Raises an Unix.Unix_error exception if 0 characters could be written before an error occurs. Continues the write operation on EINTR. Returns the number of characters written in all other cases.
val pwrite : Unix.file_descr->int ->string ->int ->int -> int
val unsafe_intr_pwrite : Unix.file_descr->int ->string ->int ->int -> int
intr_pwrite fd off buf ofs len writes up to len bytes from file descriptor fd at offset off (from the start of the file) into the string buf at offset ofs. The file offset is not changed.
intr_pwrite repeats the write operation until all characters have been written or an error occurs. Raises an Unix.Unix_error exception if 0 characters could be written before an error occurs. Does NOT continue on EINTR. Returns the number of characters written in all other cases.
val intr_pwrite : Unix.file_descr->int ->string ->int ->int -> int
all_read fd buf ofs len reads up to len bytes from file descriptor fd into the string buf at offset ofs.
all_read repeats the read operation until all characters have been read or an error occurs. Returns less than the number of characters requested on EAGAIN, EWOULDBLOCK or End-of-file but only ever returns 0 on End-of-file. Continues the read operation on EINTR. Raises an Unix.Unix_error exception in all other cases.
read fd buf ofs len reads up to len bytes from file descriptor fd into the string buf at offset ofs.
read repeats the read operation until all characters have been read or an error occurs. Raises an Unix.Unix_error exception if 0 characters could be read before an error occurs. Continues the read operation on EINTR. Returns the number of characters written in all other cases.
intr_read fd buf ofs len reads up to len bytes from file descriptor fd into the string buf at offset ofs.
intr_read repeats the read operation until all characters have been read or an error occurs. Raises an Unix.Unix_error exception if 0 characters could be read before an error occurs. Does NOT continue on EINTR. Returns the number of characters written in all other cases.
val unsafe_all_write : Unix.file_descr->string ->int ->int -> int
all_write fd buf ofs len writes up to len bytes from file descriptor fd into the string buf at offset ofs.
all_write repeats the write operation until all characters have been written or an error occurs. Returns less than the number of characters requested on EAGAIN, EWOULDBLOCK but never 0. Continues the write operation on EINTR. Raises an Unix.Unix_error exception in all other cases.
val unsafe_single_write : Unix.file_descr->string ->int ->int -> int
single_write fd buf ofs len writes up to len bytes from file descriptor fd into the string buf at offset ofs.
single_write attempts to write only once. Returns the number of characters written or raises an Unix.Unix_error exception.
val single_write : Unix.file_descr->string ->int ->int -> int
val unsafe_write : Unix.file_descr->string ->int ->int -> int
write fd buf ofs len writes up to len bytes from file descriptor fd into the string buf at offset ofs.
write repeats the write operation until all characters have been written or an error occurs. Raises an Unix.Unix_error exception if 0 characters could be written before an error occurs. Continues the write operation on EINTR. Returns the number of characters written in all other cases.
val unsafe_intr_write : Unix.file_descr->string ->int ->int -> int
intr_write fd buf ofs len writes up to len bytes from file descriptor fd into the string buf at offset ofs.
intr_write repeats the write operation until all characters have been written or an error occurs. Raises an Unix.Unix_error exception if 0 characters could be written before an error occurs. Does NOT continue on EINTR. Returns the number of characters written in all other cases.
File operations on large files. This sub-module provides 64-bit variants of the functions ExtUnix.fadvise (for predeclaring an access pattern for file data), ExtUnix.fallocate (for allocating disk space for a file), ExtUnix.all_pread, ExtUnix.single_pread, ExtUnix.pread, ExtUnix.intr_pread, ExtUnix.all_pwrite, ExtUnix.single_pwrite, ExtUnix.pwrite and ExtUnix.intr_pwrite (for reading from or writing to a file descriptor at a given offset). These alternate functions represent positions and sizes by 64-bit integers (type int64) instead of regular integers (type int), thus allowing operating on files whose sizes are greater than max_int.
mount system call
type mount_flag =
| MS_RDONLY
| MS_NOSUID
| MS_NODEV
| MS_NOEXEC
| MS_SYNCHRONOUS
| MS_REMOUNT
| MS_MANDLOCK
| MS_DIRSYNC
| MS_NOATIME
| MS_NODIRATIME
| MS_BIND
| MS_MOVE
| MS_REC
| MS_SILENT
| MS_POSIXACL
| MS_UNBINDABLE
| MS_PRIVATE
| MS_SLAVE
| MS_SHARED
| MS_RELATIME
| MS_KERNMOUNT
| MS_I_VERSION
| MS_STRICTATIME
| MS_NOUSER
val mount :
source:string ->target:string ->fstype:string ->mount_flag list->data:string ->
unit
setpgid pid pgid sets the process group of the process specified by pid to pgid. If pid is zero, then the process ID of the calling process is used. If pgid is zero, then the PGID of the process specified by pid is made the same as its process ID.
val getpgid : int -> int
getpgid pid returns the PGID of the process specified by pid. If pid is zero, the process ID of the calling process is used.
val getsid : int -> int
getsid pid returns the session ID of the process specified by pid. If pid is zero, the process ID of the calling process is used.
val setreuid : int ->int -> unit
setreuid ruid euid sets real and effective user IDs of the calling process. Supplying a value of -1 for either the real or effective user ID forces the system to leave that ID unchanged.
val setregid : int ->int -> unit
setregid rgid egid sets real and effective group IDs of the calling process. Supplying a value of -1 for either the real or effective group ID forces the system to leave that ID unchanged.
val setresuid : int ->int ->int -> unit
setresuid ruid euid suid sets real, effective and saved user IDs of the calling process. Supplying a value of -1 for either the real or effective user ID forces the system to leave that ID unchanged.
val setresgid : int ->int ->int -> unit
setresgid rgid egid sgid sets real, effective and saved group IDs of the calling process. Supplying a value of -1 for either the real or effective group ID forces the system to leave that ID unchanged.
the list of AF_INET and AF_INET6 interfaces and corresponding addresses (may change)
type socket_int_option =
| TCP_KEEPCNT
(*
The maximum number of keepalive probes TCP should send before dropping the connection
*)
| TCP_KEEPIDLE
(*
The time (in seconds) the connection needs to remain idle before TCP starts sending keepalive probes, if the socket option SO_KEEPALIVE has been set on this socket
*)
| TCP_KEEPINTVL
(*
The time (in seconds) between individual keepalive probes
*)
| SO_ATTACH_BPF
(*
file descriptor returned by the bpf(2), with program of type BPF_PROG_TYPE_SOCKET_FILTER
*)
| SO_ATTACH_REUSEPORT_EBPF
(*
same as for SO_ATTACH_BPF
*)
Extra socket options with integer value not covered in Unix module. NB: Not all options available on all platforms, use have_sockopt_int to check at runtime (even when function is defined in Specific module).
type socket_bool_option =
| SO_REUSEPORT
(*
Permits multiple AF_INET or AF_INET6 sockets to be bound to an identical socket address.
*)
| SO_LOCK_FILTER
(*
Prevent changing the filters associated with the socket
*)
type socket_unit_option =
| SO_DETACH_FILTER
(*
Remove classic or extended BPF program attached to a socket
signalfd ?fd sigs flags () If the first optional argument is omitted, then a new file descriptor is allocated. Otherwise, the given file descriptor is modified (in which case it must have been created with signalfd previously). When you are done with the fd, remember to Unix.close it. Do not forget to block sigs with Unix.sigprocmask to prevent signal handling according to default dispositions.
type ssi
This type represents signal information that is read(2) from the signalfd.
This function is the converse of the strftime function. strptime fmt data convert a string containing time information data into a tm struct according to the format specified by fmt.
This functions is the converse of the strptime function. strftime fmt data converts a tm structure data into a string according to the format specified by fmt.
val tzname : bool -> string
tzname isdst
parameterisdst
specifies whether daylight saving is in effect
returns
abbreviated name of the current timezone
val timezone : unit -> int * bool
returns
timezone (seconds West of UTC) and daylight (whether there is time during the year when daylight saving time applies in this timezone)
setenv name value overwrite adds the variable name to the environment with the value value, if name does not already exist or overwrite is true
val unsetenv : string -> unit
unsetenv name removes variable name from the environment. If name does not exist in the environment, then the function succeeds, and the environment is unchanged.
val clearenv : unit -> unit
Clear the environment of all name-value pairs
Temporary directories
val mkdtemp : string -> string
mkdtemp template creates a unique temporary directory (with permissions 0700). Last six characters of template must be "XXXXXX".
val mkstemp : ?suffix:string ->string ->Unix.file_descr * string
mkstemp ?(suffix="") prefix generates a unique temporary filename in the form prefixXXXXXXsuffix, creates and opens the file, and returns an open file descriptor and name for the file.
mkostemp ?(suffix="") ?(flags=[]) prefix generates a unique temporary filename in the form prefixXXXXXXsuffix, creates and opens the file with flags, and returns an open file descriptor and name for the file.
Reads sender credentials from a file descriptor, returning a 3-element tuple containing the sender process' PID, UID and GID.
fexecve
author Andre Nathan
val fexecve : Unix.file_descr->string array->string array->'a
fexecve fd args env executes the program in file represented by file descriptor fd with arguments args and environment variables given by env. As with the execv* functions, on success fexecve never returns; the current process is replaced by the new one.
sendfd sock fd sends a file descriptor fd through a UNIX domain socket sock. This will send a sentinel message at the same time, otherwise sendmsg will not pass the file descriptor.
Receive a message sent through a UNIX domain socket. Closes and ignores file descriptors.
sysconf
author Roman Vorobets
type sysconf_name =
| ARG_MAX
(*
The maximum length of the arguments to the exec(3) family of functions.
*)
| CHILD_MAX
(*
The max number of simultaneous processes per user ID.
*)
| HOST_NAME_MAX
(*
Max length of a hostname, not including the terminating null byte, as returned by gethostname(2).
*)
| LOGIN_NAME_MAX
(*
Maximum length of a login name, including the terminating null byte.
*)
| CLK_TCK
(*
The number of clock ticks per second.
*)
| OPEN_MAX
(*
The maximum number of files that a process can have open at any time.
*)
| PAGESIZE
(*
Size of a page in bytes.
*)
| RE_DUP_MAX
(*
The number of repeated occurrences of a BRE permitted by regexec(3) and regcomp(3).
*)
| STREAM_MAX
(*
The maximum number of streams that a process can have open at any time.
*)
| SYMLOOP_MAX
(*
The maximum number of symbolic links seen in a pathname before resolution returns ELOOP.
*)
| TTY_NAME_MAX
(*
The maximum length of terminal device name, including the terminating null byte.
*)
| TZNAME_MAX
(*
The maximum number of bytes in a timezone name.
*)
| POSIX_VERSION
(*
Indicates the year and month the POSIX.1 standard was approved in the format YYYYMML; the value 199009L indicates the Sept. 1990 revision.
*)
| LINE_MAX
(*
The maximum length of a utility's input line, either from standard input or from a file. This includes space for a trailing newline.
*)
| POSIX2_VERSION
(*
Indicates the version of the POSIX.2 standard in the format of YYYYMML.
*)
| PHYS_PAGES
(*
The number of pages of physical memory. Note that it is possible for the product of this value and the value of PAGE_SIZE to overflow. Non-standard, may be not available
*)
| AVPHYS_PAGES
(*
The number of currently available pages of physical memory. Non-standard, may be not available
*)
| NPROCESSORS_CONF
(*
The number of processors configured. Non-standard, may be not available
*)
| NPROCESSORS_ONLN
(*
The number of processors currently online (available). Non-standard, may be not available
get configuration information at runtime, may raise Not_available for non-standard options (see above) even in Specific module
splice
author Pierre Chambart <pierre.chambart@ocamlpro.com>
type splice_flag =
| SPLICE_F_MOVE
(*
Attempt to move pages instead of copying. Only a hint to the kernel
*)
| SPLICE_F_NONBLOCK
(*
Do not block on I/O
*)
| SPLICE_F_MORE
(*
Announce that more data will be coming. Hint used by sockets
*)
| SPLICE_F_GIFT
(*
The user pages are a gift to the kernel. The application may not modify this memory ever, or page cache and on-disk data may differ. Gifting pages to the kernel means that a subsequent splice(2) SPLICE_F_MOVE can successfully move the pages; if this flag is not specified, then a subsequent splice(2) SPLICE_F_MOVE must copy the pages. Data must also be properly page aligned, both in memory and length.
splice fd_in off_in fd_out off_out len flags moves data between two file descriptors without copying between kernel address space and user address space. It transfers up to len bytes of data from the file descriptor fd_in to the file descriptor fd_out, where one of the descriptors must refer to a pipe.
If fd_in refers to a pipe, then off_in must be None. If fd_in does not refer to a pipe and off_in is None, then bytes are read from fd_in starting from the current file offset, and the current file offset is adjusted appropriately. If fd_in does not refer to a pipe and off_in is Some n, then n mspecifies the starting offset from which bytes will be read from fd_in; in this case, the current file offset of fd_in is not changed. Analogous statements apply for fd_out and off_out.
returns
the number of bytes spliced to or from the pipe. A return value of 0 means that there was no data to transfer, and it would not make sense to block, because there are no writers connected to the write end of the pipe referred to by fd_in.
tee fd_in fd_out len flags duplicates up to len bytes of data from the pipe fd_in to the pipe fd_out. It does not consume the data that is duplicated from fd_in; therefore, that data can be copied by a subsequent splice.
returns
the number of bytes that were duplicated between the input and output. A return value of 0 means that there was no data to transfer, and it would not make sense to block, because there are no writers connected to the write end of the pipe referred to by fd_in.