Prelude.UnixAdditional Unix functions.
include module type of struct include Unix endtype error = Unix.error = | E2BIG| EACCES| EAGAIN| EBADF| EBUSY| ECHILD| EDEADLK| EDOM| EEXIST| EFAULT| EFBIG| EINTR| EINVAL| EIO| EISDIR| EMFILE| EMLINK| ENAMETOOLONG| ENFILE| ENODEV| ENOENT| ENOEXEC| ENOLCK| ENOMEM| ENOSPC| ENOSYS| ENOTDIR| ENOTEMPTY| ENOTTY| ENXIO| EPERM| EPIPE| ERANGE| EROFS| ESPIPE| ESRCH| EXDEV| EWOULDBLOCK| EINPROGRESS| EALREADY| ENOTSOCK| EDESTADDRREQ| EMSGSIZE| EPROTOTYPE| ENOPROTOOPT| EPROTONOSUPPORT| ESOCKTNOSUPPORT| EOPNOTSUPP| EPFNOSUPPORT| EAFNOSUPPORT| EADDRINUSE| EADDRNOTAVAIL| ENETDOWN| ENETUNREACH| ENETRESET| ECONNABORTED| ECONNRESET| ENOBUFS| EISCONN| ENOTCONN| ESHUTDOWN| ETOOMANYREFS| ETIMEDOUT| ECONNREFUSED| EHOSTDOWN| EHOSTUNREACH| ELOOP| EOVERFLOW| EUNKNOWNERR of intexception Unix_error of error * string * stringval error_message : error -> stringval wait : unit -> int * process_statusval waitpid : wait_flag list -> int -> int * process_statusval system : string -> process_statusval stdin : file_descrval stdout : file_descrval stderr : file_descrval openfile : string -> open_flag list -> file_perm -> file_descrval close : file_descr -> unitval fsync : file_descr -> unitval read : file_descr -> bytes -> int -> int -> intval write : file_descr -> bytes -> int -> int -> intval single_write : file_descr -> bytes -> int -> int -> intval write_substring : file_descr -> string -> int -> int -> intval single_write_substring : file_descr -> string -> int -> int -> intval in_channel_of_descr : file_descr -> Stdlib.in_channelval out_channel_of_descr : file_descr -> Stdlib.out_channelval descr_of_in_channel : Stdlib.in_channel -> file_descrval descr_of_out_channel : Stdlib.out_channel -> file_descrval lseek : file_descr -> int -> seek_command -> intval ftruncate : file_descr -> int -> unitval stat : string -> statsval lstat : string -> statsval fstat : file_descr -> statsval isatty : file_descr -> boolval map_file :
file_descr ->
?pos:int64 ->
('a, 'b) Stdlib.Bigarray.kind ->
'c Stdlib.Bigarray.layout ->
bool ->
int array ->
('a, 'b, 'c) Stdlib.Bigarray.Genarray.tval chmod : string -> file_perm -> unitval fchmod : file_descr -> file_perm -> unitval fchown : file_descr -> int -> int -> unitval access : string -> access_permission list -> unitval dup : ?cloexec:bool -> file_descr -> file_descrval dup2 : ?cloexec:bool -> file_descr -> file_descr -> unitval set_nonblock : file_descr -> unitval clear_nonblock : file_descr -> unitval set_close_on_exec : file_descr -> unitval clear_close_on_exec : file_descr -> unitval mkdir : string -> file_perm -> unitval opendir : string -> dir_handleval readdir : dir_handle -> stringval rewinddir : dir_handle -> unitval closedir : dir_handle -> unitval pipe : ?cloexec:bool -> unit -> file_descr * file_descrval mkfifo : string -> file_perm -> unitval create_process :
string ->
string array ->
file_descr ->
file_descr ->
file_descr ->
intval create_process_env :
string ->
string array ->
string array ->
file_descr ->
file_descr ->
file_descr ->
intval close_process_in : Stdlib.in_channel -> process_statusval close_process_out : Stdlib.out_channel -> process_statusval close_process : (Stdlib.in_channel * Stdlib.out_channel) -> process_statusval close_process_full :
(Stdlib.in_channel * Stdlib.out_channel * Stdlib.in_channel) ->
process_statusval select :
file_descr list ->
file_descr list ->
file_descr list ->
float ->
file_descr list * file_descr list * file_descr listval lockf : file_descr -> lock_command -> int -> unitval sigprocmask : sigprocmask_command -> int list -> int listval gmtime : float -> tmval localtime : float -> tmval times : unit -> process_timesval getitimer : interval_timer -> interval_timer_statusval setitimer :
interval_timer ->
interval_timer_status ->
interval_timer_statusval getpwnam : string -> passwd_entryval getgrnam : string -> group_entryval getpwuid : int -> passwd_entryval getgrgid : int -> group_entryval inet_addr_of_string : string -> inet_addrval string_of_inet_addr : inet_addr -> stringval inet_addr_any : inet_addrval inet_addr_loopback : inet_addrval inet6_addr_any : inet_addrval inet6_addr_loopback : inet_addrval is_inet6_addr : inet_addr -> boolval socket : ?cloexec:bool -> socket_domain -> socket_type -> int -> file_descrval domain_of_sockaddr : sockaddr -> socket_domainval socketpair :
?cloexec:bool ->
socket_domain ->
socket_type ->
int ->
file_descr * file_descrval accept : ?cloexec:bool -> file_descr -> file_descr * sockaddrval bind : file_descr -> sockaddr -> unitval connect : file_descr -> sockaddr -> unitval listen : file_descr -> int -> unitval shutdown : file_descr -> shutdown_command -> unitval getsockname : file_descr -> sockaddrval getpeername : file_descr -> sockaddrval recv : file_descr -> bytes -> int -> int -> msg_flag list -> intval recvfrom :
file_descr ->
bytes ->
int ->
int ->
msg_flag list ->
int * sockaddrval send : file_descr -> bytes -> int -> int -> msg_flag list -> intval send_substring : file_descr -> string -> int -> int -> msg_flag list -> intval sendto :
file_descr ->
bytes ->
int ->
int ->
msg_flag list ->
sockaddr ->
intval sendto_substring :
file_descr ->
string ->
int ->
int ->
msg_flag list ->
sockaddr ->
intval getsockopt : file_descr -> socket_bool_option -> boolval setsockopt : file_descr -> socket_bool_option -> bool -> unitval getsockopt_int : file_descr -> socket_int_option -> intval setsockopt_int : file_descr -> socket_int_option -> int -> unitval getsockopt_optint : file_descr -> socket_optint_option -> int optionval setsockopt_optint :
file_descr ->
socket_optint_option ->
int option ->
unitval getsockopt_float : file_descr -> socket_float_option -> floatval setsockopt_float : file_descr -> socket_float_option -> float -> unitval getsockopt_error : file_descr -> error optionval open_connection : sockaddr -> Stdlib.in_channel * Stdlib.out_channelval establish_server :
(Stdlib.in_channel -> Stdlib.out_channel -> unit) ->
sockaddr ->
unittype host_entry = Unix.host_entry = {h_name : string;h_aliases : string array;h_addrtype : socket_domain;h_addr_list : inet_addr array;}val gethostbyname : string -> host_entryval gethostbyaddr : inet_addr -> host_entryval getprotobyname : string -> protocol_entryval getprotobynumber : int -> protocol_entryval getservbyname : string -> string -> service_entryval getservbyport : int -> string -> service_entrytype addr_info = Unix.addr_info = {ai_family : socket_domain;ai_socktype : socket_type;ai_protocol : int;ai_addr : sockaddr;ai_canonname : string;}type getaddrinfo_option = Unix.getaddrinfo_option = | AI_FAMILY of socket_domain| AI_SOCKTYPE of socket_type| AI_PROTOCOL of int| AI_NUMERICHOST| AI_CANONNAME| AI_PASSIVEval getaddrinfo : string -> string -> getaddrinfo_option list -> addr_info listval getnameinfo : sockaddr -> getnameinfo_option list -> name_infotype terminal_io = Unix.terminal_io = {mutable c_ignbrk : bool;mutable c_brkint : bool;mutable c_ignpar : bool;mutable c_parmrk : bool;mutable c_inpck : bool;mutable c_istrip : bool;mutable c_inlcr : bool;mutable c_igncr : bool;mutable c_icrnl : bool;mutable c_ixon : bool;mutable c_ixoff : bool;mutable c_opost : bool;mutable c_obaud : int;mutable c_ibaud : int;mutable c_csize : int;mutable c_cstopb : int;mutable c_cread : bool;mutable c_parenb : bool;mutable c_parodd : bool;mutable c_hupcl : bool;mutable c_clocal : bool;mutable c_isig : bool;mutable c_icanon : bool;mutable c_noflsh : bool;mutable c_echo : bool;mutable c_echoe : bool;mutable c_echok : bool;mutable c_echonl : bool;mutable c_vintr : char;mutable c_vquit : char;mutable c_verase : char;mutable c_vkill : char;mutable c_veof : char;mutable c_veol : char;mutable c_vmin : int;mutable c_vtime : int;mutable c_vstart : char;mutable c_vstop : char;}val tcgetattr : file_descr -> terminal_ioval tcsetattr : file_descr -> setattr_when -> terminal_io -> unitval tcsendbreak : file_descr -> int -> unitval tcdrain : file_descr -> unitval tcflush : file_descr -> flush_queue -> unitval tcflow : file_descr -> flow_action -> unit(to_string exn) produces a "better" (IMHO) representation of a Unix_error exception for end users.
All other exceptions are re-raised (with no trace).
(restart_on_EINTR f x) is (f x) but if evaluation is interrupted by (Unix_error (EINTR, _, _)), (f x) will be evaluated again.
This is necessary for system calls such as Unix.waitpid, Unix.select, etc, exactly as it's needed in C programming.
module Timer : sig ... endTimer functions and similar
(home ()) is the current (effective) user's home directory according to the password database.
Raises Not_found if no such entry exists.
(mkdirp ?(perm=0o755) dir) is like mkdir(1) with its -p option: there is no error if dir already exists, and we make parent directories as needed.
module Env : sig ... endFunctions for Manipulating the Environment
signals is an alist mapping OCaml signal numbers to their traditional Unix names.
(OCaml signal numbers don't match the traditional Unix signal numbers!)
(string_of_signal signal) returns the traditional name of the OCaml signal number signal.
In the event of an unknown signal, the name returned is just the integer.
module Proc : sig ... endRunning Subprocesses
module Shell : sig ... endSimple functions to interact with shell pipelines.