Module Std.Unix_ext


module Unix_ext: Unix_ext


Utility functions


val unix_error : int -> string -> string -> 'a
Raises Unix_error with a given errno, function name and argument
val exit_immediately : int -> 'a
exit_immediately exit_code immediately calls the exit system call with the given exit code without performing any other actions (unlike Pervasives.exit). Does not return.

Filesystem functions


val mknod : ?file_kind:Unix.file_kind ->
?perm:int -> ?major:int -> ?minor:int -> string -> unit
mknod ?file_kind ?perm ?major ?minor path creates a filesystem entry. Note that only FIFO-entries are guaranteed to be supported across all platforms as required by the POSIX-standard. On Linux directories and symbolic links cannot be created with this function. Use Unix.mkdir and Unix.symlink instead there respectively.
Raises
file_kind : default = S_REG (= regular file)
perm : default = 0o600 (= read/write for user only)
major : default = 0
minor : default = 0

I/O vectors


module IOVec: sig .. end
I/O-vectors for scatter/gather-operations

I/O functions


val int_of_file_descr : Unix.file_descr -> int
int_of_file_descr fd converts file descriptor fd to the internal integer value.
val file_descr_of_int : int -> Unix.file_descr
file_descr_of_int n converts an integer to a file descriptor.
val dirfd : Unix.dir_handle -> Unix.file_descr
Extract a file descriptor from a directory handle.
val sync : unit -> unit
Synchronize all filesystem buffers with disk.
val fsync : Unix.file_descr -> unit
Synchronize the kernel buffers of a given file descriptor with disk.
val fdatasync : Unix.file_descr -> unit
Synchronize the kernel buffers of a given file descriptor with disk, but do not necessarily write file attributes.
val readdir_ino : Unix.dir_handle -> string * nativeint
readdir_ino dh return the next entry in a directory (((filename, inode)).
Raises End_of_file when the end of the directory has been reached.
val read_assume_fd_is_nonblocking : Unix.file_descr -> ?pos:int -> ?len:int -> string -> int
read_assume_fd_is_nonblocking fd ?pos ?len buf calls the system call read ASSUMING THAT IT IS NOT GOING TO BLOCK. Reads at most len bytes into buffer buf starting at position pos.
Raises Returns the number of bytes actually read.
pos : = 0
len : = String.length buf - pos
val write_assume_fd_is_nonblocking : Unix.file_descr -> ?pos:int -> ?len:int -> string -> int
write_assume_fd_is_nonblocking fd ?pos ?len buf calls the system call write ASSUMING THAT IT IS NOT GOING TO BLOCK. Writes at most len bytes from buffer buf starting at position pos.
Raises Returns the number of bytes actually written.
pos : = 0
len : = String.length buf - pos
val writev_assume_fd_is_nonblocking : Unix.file_descr -> ?count:int -> string IOVec.t array -> int
writev_assume_fd_is_nonblocking fd ?count iovecs calls the system call writev ASSUMING THAT IT IS NOT GOING TO BLOCK using count I/O-vectors iovecs.
Raises Returns the number of bytes actually written.
val writev : Unix.file_descr -> ?count:int -> string IOVec.t array -> int
writev fd ?count iovecs like Unix_ext.writev_assume_fd_is_nonblocking, but does not require the descriptor to not block. If you feel you have to use this function, you should probably have chosen I/O-vectors that build on bigstrings, because this function has to internally blit the I/O-vectors (ordinary OCaml strings) to intermediate buffers on the C-heap.
Raises Returns the number of bytes actually written.
val pselect : Unix.file_descr list ->
Unix.file_descr list ->
Unix.file_descr list ->
float ->
int list ->
Unix.file_descr list * Unix.file_descr list * Unix.file_descr list
pselect rfds wfds efds timeout sigmask like Unix.select but also allows one to wait for the arrival of signals.

Clock functions



Type of Unix-clocks
module Clock: sig .. end

Resource limits


module RLimit: sig .. end
module Resource_usage: sig .. end
Resource usage -- For details, "man getrusage"

System configuration



type sysconf =
| ARG_MAX
| CHILD_MAX
| HOST_NAME_MAX
| LOGIN_NAME_MAX
| OPEN_MAX
| PAGESIZE
| RE_DUP_MAX
| STREAM_MAX
| SYMLOOP_MAX
| TTY_NAME_MAX
| TZNAME_MAX
| POSIX_VERSION
| PHYS_PAGES
| AVPHYS_PAGES
| IOV_MAX
val sysconf : sysconf -> int64

POSIX thread functions


val mutex_timedlock : Mutex.t -> float -> bool
mutex_timedlock mtx timeout tries to lock mtx, but returns once timeout expires. Note that timeout is an absolute Unix-time to prevent time-related race conditions.
Returns false iff the timer expired without the lock being acquired. See man pthread_mutex_timedlock for details.
val condition_timedwait : Condition.t -> Mutex.t -> float -> bool
condition_timedwait cnd mtx timeout waits on condition variable cond with mutex mtx until either the condition is signalled, or until timeout expires. Note that timeout is an absolute Unix-time to prevent time-related race conditions.
Returns false iff the timer expired, but this does not mean that the condition is not true due to an unavoidable race condition in the system call. See man pthread_cond_timedwait for details.
val create_error_checking_mutex : unit -> Mutex.t
create_error_checking_mutex () like Mutex.create, but creates an error-checking mutex. Locking a mutex twice from the same thread, unlocking an unlocked mutex, or unlocking a mutex not held by the thread will result in a Sys_error exception.

Pathname resolution


val realpath : string -> string
realpath path
Raises Unix_error on errors.
Returns the canonicalized absolute pathname of path.

Temporary file and directory creation


val mkstemp : string -> string * Unix.file_descr
mkstemp prefix creates and opens a unique temporary file with prefix, automatically appending a suffix of six random characters to make the name unique.
Raises Unix_error on errors.
val mkdtemp : string -> string
mkdtemp prefix creates a temporary directory with prefix, automatically appending a suffix of six random characters to make the name unique.
Raises Unix_error on errors. k

Signal handling


val abort : unit -> 'a

User id, group id


val initgroups : string -> int -> unit

Globbing and shell expansion


module Fnmatch_flags: sig .. end
val fnmatch : ?flags:Fnmatch_flags.t -> pat:string -> string -> bool
module Wordexp_flags: sig .. end
val wordexp : ?flags:Wordexp_flags.t -> string -> string array

Additional IP functionality


val if_indextoname : int -> string
val mcast_join : ?ifname:string -> Unix.file_descr -> Unix.sockaddr -> unit
mcast_join ?ifname sock addr join a multicast group at addr with socket sock, optionally using network interface ifname.
ifname : default = any interface
val mcast_leave : ?ifname:string -> Unix.file_descr -> Unix.sockaddr -> unit
mcast_leave ?ifname sock addr leaves a multicast group at addr with socket sock, optionally using network interface ifname.
ifname : default = any interface