Unix_syscalls provides an interface to many of the functions in OCaml's standard Unix module. It uses a deferred in the return type of functions that would block. The idea is that in an Async program one does not use the standard Unix module, since in doing so one could accidentally block the whole program.

There are also a number of cosmetic changes (e.g. polymorphic variants) and other improvements (e.g. phantom types on sockets) over the standard Unix module.

module Exit : module type of Core.Std.Unix.Exit
module Exit_or_signal : module type of Core.Std.Unix.Exit_or_signal
module Exit_or_signal_or_stop : module type of Core.Std.Unix.Exit_or_signal_or_stop
val system : string -> Exit_or_signal.t Import.Deferred.t
val system_exn : string -> unit Import.Deferred.t
val getpid : unit -> Core.Std.Pid.t
val getppid : unit -> Core.Std.Pid.t option
val getppid_exn : unit -> Core.Std.Pid.t
val this_process_became_child_of_init : ?poll_delay:Core.Std.Time.Span.t -> unit -> unit Import.Deferred.t
this_process_became_child_of_init returns a deferred that becomes determined when the current process becomes a child of init(8). This is useful to determine if one's parent has died, because in that case init will becomes one's parent.

See Linux_ext.pr_set_pdeathsig : Signal.t -> unit for related way to get information about parent death.

val nice : int -> int
val cores : (unit -> int Import.Deferred.t) Core.Std.Or_error.t
cores () Returns the number of cores
type open_flag = [ `Append
| `Creat
| `Dsync
| `Excl
| `Noctty
| `Nonblock
| `Rdonly
| `Rdwr
| `Rsync
| `Sync
| `Trunc
| `Wronly ]
type file_perm = int
val openfile : ?perm:file_perm ->
?close_on_exec:bool ->
string -> mode:open_flag list -> Fd.t Import.Deferred.t
val with_file : ?exclusive:[ `Read | `Write ] ->
?perm:file_perm ->
string ->
mode:open_flag list ->
f:(Fd.t -> 'a Import.Deferred.t) -> 'a Import.Deferred.t
with_file file ~mode ~perm ~f ?exclusive opens file, and applies f to the resulting file descriptor. When the result of f becomes determined, it closes the descriptor and returns the result of f. If exclusive is supplied, then the file descriptor is locked before calling f and unlocked after calling f.
module Open_flags : module type of Core.Std.Unix.Open_flags
val fcntl_getfl : Fd.t -> Open_flags.t Import.Deferred.t
fcntl_getfl and fcntl_setf are deferred wrappers around the corresponding functions in Core.Unix for accessing the open-file-descriptor table.
val fcntl_setfl : Fd.t -> Open_flags.t -> unit Import.Deferred.t
val close : ?should_close_file_descriptor:bool -> Fd.t -> unit Import.Deferred.t
close fd closes the file descriptor fd, and raises an exception if fd has already been closed.

In some situations, one may need to cause Async to release an fd that it is managing without closing the underlying file descriptor. In that case, one should supply ~should_close_file_descriptor:false, which will skip the underlying close() system call.

val lseek : Fd.t -> int64 -> mode:[< `Cur | `End | `Set ] -> int64 Import.Deferred.t
val truncate : string -> len:int64 -> unit Import.Deferred.t
val ftruncate : Fd.t -> len:int64 -> unit Import.Deferred.t
val fsync : Fd.t -> unit Import.Deferred.t
val fdatasync : Fd.t -> unit Import.Deferred.t
val sync : unit -> unit Import.Deferred.t
val lockf : ?len:Core.Std.Int64.t -> Fd.t -> [ `Read | `Write ] -> unit Import.Deferred.t
lockf fd read_or_write ?len exclusively locks for reading/writing the section of the open file fd specified by the current file position and len (see man lockf). It returns when the lock has been acquired. It raises if fd is closed.
val try_lockf : ?len:Core.Std.Int64.t -> Fd.t -> [ `Read | `Write ] -> bool
try_lockf fd read_or_write ?len attempts to exclusively lock for reading/writing the section of the open file fd specified by the current file position and len (see man lockf). It returns true if it acquired the lock. It raises if fd is closed.
val test_lockf : ?len:Core.Std.Int64.t -> Fd.t -> bool
lockf_is_locked fd ?len checks the lock on section of the open file fd specified by the current file position and len (see man lockf). If the section is unlocked or locked by this process, it returns true, else it returns false. It raises if fd is closed.
val unlockf : ?len:Core.Std.Int64.t -> Fd.t -> unit
unlockf fd ?len unlocks the section of the open file fd specified by the current file position and len (see man lockf). It raises if fd is closed.
module File_kind : sig .. end
type t = [ `Block | `Char | `Directory | `Fifo | `File | `Link | `Socket ]
val t_of_sexp : Sexplib.Sexp.t -> t
val __t_of_sexp__ : Sexplib.Sexp.t -> t
val sexp_of_t : t -> Sexplib.Sexp.t
module Stats : sig .. end
type t = {
dev : int;
ino : int;
kind : File_kind.t;
perm : file_perm;
nlink : int;
uid : int;
gid : int;
rdev : int;
size : int64;
atime : Core.Std.Time.t;
mtime : Core.Std.Time.t;
ctime : Core.Std.Time.t;
}
val ctime : t -> Core.Std.Time.t
val mtime : t -> Core.Std.Time.t
val atime : t -> Core.Std.Time.t
val size : t -> int64
val rdev : t -> int
val gid : t -> int
val uid : t -> int
val nlink : t -> int
val perm : t -> file_perm
val kind : t -> File_kind.t
val ino : t -> int
val dev : t -> int
module Fields : sig .. end
val names : string list
val ctime : (t, Core.Std.Time.t) Fieldslib.Field.t
val mtime : (t, Core.Std.Time.t) Fieldslib.Field.t
val atime : (t, Core.Std.Time.t) Fieldslib.Field.t
val size : (t, int64) Fieldslib.Field.t
val rdev : (t, int) Fieldslib.Field.t
val gid : (t, int) Fieldslib.Field.t
val uid : (t, int) Fieldslib.Field.t
val nlink : (t, int) Fieldslib.Field.t
val perm : (t, file_perm) Fieldslib.Field.t
val kind : (t, File_kind.t) Fieldslib.Field.t
val ino : (t, int) Fieldslib.Field.t
val dev : (t, int) Fieldslib.Field.t
val fold : init:'acc__ ->
dev:('acc__ -> (t, int) Fieldslib.Field.t -> 'acc__) ->
ino:('acc__ -> (t, int) Fieldslib.Field.t -> 'acc__) ->
kind:('acc__ -> (t, File_kind.t) Fieldslib.Field.t -> 'acc__) ->
perm:('acc__ -> (t, file_perm) Fieldslib.Field.t -> 'acc__) ->
nlink:('acc__ -> (t, int) Fieldslib.Field.t -> 'acc__) ->
uid:('acc__ -> (t, int) Fieldslib.Field.t -> 'acc__) ->
gid:('acc__ -> (t, int) Fieldslib.Field.t -> 'acc__) ->
rdev:('acc__ -> (t, int) Fieldslib.Field.t -> 'acc__) ->
size:('acc__ -> (t, int64) Fieldslib.Field.t -> 'acc__) ->
atime:('acc__ -> (t, Core.Std.Time.t) Fieldslib.Field.t -> 'acc__) ->
mtime:('acc__ -> (t, Core.Std.Time.t) Fieldslib.Field.t -> 'acc__) ->
ctime:('acc__ -> (t, Core.Std.Time.t) Fieldslib.Field.t -> 'acc__) -> 'acc__
val make_creator : dev:((t, int) Fieldslib.Field.t ->
     'compile_acc__ -> ('input__ -> int) * 'compile_acc__) ->
ino:((t, int) Fieldslib.Field.t ->
     'compile_acc__ -> ('input__ -> int) * 'compile_acc__) ->
kind:((t, File_kind.t) Fieldslib.Field.t ->
      'compile_acc__ -> ('input__ -> File_kind.t) * 'compile_acc__) ->
perm:((t, file_perm) Fieldslib.Field.t ->
      'compile_acc__ -> ('input__ -> file_perm) * 'compile_acc__) ->
nlink:((t, int) Fieldslib.Field.t ->
       'compile_acc__ -> ('input__ -> int) * 'compile_acc__) ->
uid:((t, int) Fieldslib.Field.t ->
     'compile_acc__ -> ('input__ -> int) * 'compile_acc__) ->
gid:((t, int) Fieldslib.Field.t ->
     'compile_acc__ -> ('input__ -> int) * 'compile_acc__) ->
rdev:((t, int) Fieldslib.Field.t ->
      'compile_acc__ -> ('input__ -> int) * 'compile_acc__) ->
size:((t, int64) Fieldslib.Field.t ->
      'compile_acc__ -> ('input__ -> int64) * 'compile_acc__) ->
atime:((t, Core.Std.Time.t) Fieldslib.Field.t ->
       'compile_acc__ -> ('input__ -> Core.Std.Time.t) * 'compile_acc__) ->
mtime:((t, Core.Std.Time.t) Fieldslib.Field.t ->
       'compile_acc__ -> ('input__ -> Core.Std.Time.t) * 'compile_acc__) ->
ctime:((t, Core.Std.Time.t) Fieldslib.Field.t ->
       'compile_acc__ -> ('input__ -> Core.Std.Time.t) * 'compile_acc__) ->
'compile_acc__ -> ('input__ -> t) * 'compile_acc__
val create : dev:int ->
ino:int ->
kind:File_kind.t ->
perm:file_perm ->
nlink:int ->
uid:int ->
gid:int ->
rdev:int ->
size:int64 ->
atime:Core.Std.Time.t -> mtime:Core.Std.Time.t -> ctime:Core.Std.Time.t -> t
val map : dev:((t, int) Fieldslib.Field.t -> int) ->
ino:((t, int) Fieldslib.Field.t -> int) ->
kind:((t, File_kind.t) Fieldslib.Field.t -> File_kind.t) ->
perm:((t, file_perm) Fieldslib.Field.t -> file_perm) ->
nlink:((t, int) Fieldslib.Field.t -> int) ->
uid:((t, int) Fieldslib.Field.t -> int) ->
gid:((t, int) Fieldslib.Field.t -> int) ->
rdev:((t, int) Fieldslib.Field.t -> int) ->
size:((t, int64) Fieldslib.Field.t -> int64) ->
atime:((t, Core.Std.Time.t) Fieldslib.Field.t -> Core.Std.Time.t) ->
mtime:((t, Core.Std.Time.t) Fieldslib.Field.t -> Core.Std.Time.t) ->
ctime:((t, Core.Std.Time.t) Fieldslib.Field.t -> Core.Std.Time.t) -> t
val iter : dev:((t, int) Fieldslib.Field.t -> unit) ->
ino:((t, int) Fieldslib.Field.t -> unit) ->
kind:((t, File_kind.t) Fieldslib.Field.t -> unit) ->
perm:((t, file_perm) Fieldslib.Field.t -> unit) ->
nlink:((t, int) Fieldslib.Field.t -> unit) ->
uid:((t, int) Fieldslib.Field.t -> unit) ->
gid:((t, int) Fieldslib.Field.t -> unit) ->
rdev:((t, int) Fieldslib.Field.t -> unit) ->
size:((t, int64) Fieldslib.Field.t -> unit) ->
atime:((t, Core.Std.Time.t) Fieldslib.Field.t -> unit) ->
mtime:((t, Core.Std.Time.t) Fieldslib.Field.t -> unit) ->
ctime:((t, Core.Std.Time.t) Fieldslib.Field.t -> unit) -> unit
val for_all : dev:((t, int) Fieldslib.Field.t -> bool) ->
ino:((t, int) Fieldslib.Field.t -> bool) ->
kind:((t, File_kind.t) Fieldslib.Field.t -> bool) ->
perm:((t, file_perm) Fieldslib.Field.t -> bool) ->
nlink:((t, int) Fieldslib.Field.t -> bool) ->
uid:((t, int) Fieldslib.Field.t -> bool) ->
gid:((t, int) Fieldslib.Field.t -> bool) ->
rdev:((t, int) Fieldslib.Field.t -> bool) ->
size:((t, int64) Fieldslib.Field.t -> bool) ->
atime:((t, Core.Std.Time.t) Fieldslib.Field.t -> bool) ->
mtime:((t, Core.Std.Time.t) Fieldslib.Field.t -> bool) ->
ctime:((t, Core.Std.Time.t) Fieldslib.Field.t -> bool) -> bool
val exists : dev:((t, int) Fieldslib.Field.t -> bool) ->
ino:((t, int) Fieldslib.Field.t -> bool) ->
kind:((t, File_kind.t) Fieldslib.Field.t -> bool) ->
perm:((t, file_perm) Fieldslib.Field.t -> bool) ->
nlink:((t, int) Fieldslib.Field.t -> bool) ->
uid:((t, int) Fieldslib.Field.t -> bool) ->
gid:((t, int) Fieldslib.Field.t -> bool) ->
rdev:((t, int) Fieldslib.Field.t -> bool) ->
size:((t, int64) Fieldslib.Field.t -> bool) ->
atime:((t, Core.Std.Time.t) Fieldslib.Field.t -> bool) ->
mtime:((t, Core.Std.Time.t) Fieldslib.Field.t -> bool) ->
ctime:((t, Core.Std.Time.t) Fieldslib.Field.t -> bool) -> bool
val to_list : dev:((t, int) Fieldslib.Field.t -> 'elem__) ->
ino:((t, int) Fieldslib.Field.t -> 'elem__) ->
kind:((t, File_kind.t) Fieldslib.Field.t -> 'elem__) ->
perm:((t, file_perm) Fieldslib.Field.t -> 'elem__) ->
nlink:((t, int) Fieldslib.Field.t -> 'elem__) ->
uid:((t, int) Fieldslib.Field.t -> 'elem__) ->
gid:((t, int) Fieldslib.Field.t -> 'elem__) ->
rdev:((t, int) Fieldslib.Field.t -> 'elem__) ->
size:((t, int64) Fieldslib.Field.t -> 'elem__) ->
atime:((t, Core.Std.Time.t) Fieldslib.Field.t -> 'elem__) ->
mtime:((t, Core.Std.Time.t) Fieldslib.Field.t -> 'elem__) ->
ctime:((t, Core.Std.Time.t) Fieldslib.Field.t -> 'elem__) -> 'elem__ list
val map_poly : ([< `Read | `Set_and_create ], t, 'x0) Fieldslib.Field.user -> 'x0 list
module Direct : sig .. end
val iter : t ->
dev:((t, int) Fieldslib.Field.t -> t -> int -> unit) ->
ino:((t, int) Fieldslib.Field.t -> t -> int -> unit) ->
kind:((t, File_kind.t) Fieldslib.Field.t -> t -> File_kind.t -> unit) ->
perm:((t, file_perm) Fieldslib.Field.t -> t -> file_perm -> unit) ->
nlink:((t, int) Fieldslib.Field.t -> t -> int -> unit) ->
uid:((t, int) Fieldslib.Field.t -> t -> int -> unit) ->
gid:((t, int) Fieldslib.Field.t -> t -> int -> unit) ->
rdev:((t, int) Fieldslib.Field.t -> t -> int -> unit) ->
size:((t, int64) Fieldslib.Field.t -> t -> int64 -> unit) ->
atime:((t, Core.Std.Time.t) Fieldslib.Field.t -> t -> Core.Std.Time.t -> unit) ->
mtime:((t, Core.Std.Time.t) Fieldslib.Field.t -> t -> Core.Std.Time.t -> unit) ->
ctime:((t, Core.Std.Time.t) Fieldslib.Field.t -> t -> Core.Std.Time.t -> unit) ->
unit
val fold : t ->
init:'acc__ ->
dev:('acc__ -> (t, int) Fieldslib.Field.t -> t -> int -> 'acc__) ->
ino:('acc__ -> (t, int) Fieldslib.Field.t -> t -> int -> 'acc__) ->
kind:('acc__ ->
      (t, File_kind.t) Fieldslib.Field.t -> t -> File_kind.t -> 'acc__) ->
perm:('acc__ -> (t, file_perm) Fieldslib.Field.t -> t -> file_perm -> 'acc__) ->
nlink:('acc__ -> (t, int) Fieldslib.Field.t -> t -> int -> 'acc__) ->
uid:('acc__ -> (t, int) Fieldslib.Field.t -> t -> int -> 'acc__) ->
gid:('acc__ -> (t, int) Fieldslib.Field.t -> t -> int -> 'acc__) ->
rdev:('acc__ -> (t, int) Fieldslib.Field.t -> t -> int -> 'acc__) ->
size:('acc__ -> (t, int64) Fieldslib.Field.t -> t -> int64 -> 'acc__) ->
atime:('acc__ ->
       (t, Core.Std.Time.t) Fieldslib.Field.t ->
       t -> Core.Std.Time.t -> 'acc__) ->
mtime:('acc__ ->
       (t, Core.Std.Time.t) Fieldslib.Field.t ->
       t -> Core.Std.Time.t -> 'acc__) ->
ctime:('acc__ ->
       (t, Core.Std.Time.t) Fieldslib.Field.t ->
       t -> Core.Std.Time.t -> 'acc__) ->
'acc__
val to_string : t -> string
val t_of_sexp : Sexplib.Sexp.t -> t
val sexp_of_t : t -> Sexplib.Sexp.t
val fstat : Fd.t -> Stats.t Import.Deferred.t
val stat : string -> Stats.t Import.Deferred.t
val lstat : string -> Stats.t Import.Deferred.t
val unlink : string -> unit Import.Deferred.t
val remove : string -> unit Import.Deferred.t
val rename : src:string -> dst:string -> unit Import.Deferred.t
val link : ?force:bool ->
target:string -> link_name:string -> unit -> unit Import.Deferred.t
val chmod : string -> perm:file_perm -> unit Import.Deferred.t
val fchmod : Fd.t -> perm:file_perm -> unit Import.Deferred.t
val chown : string -> uid:int -> gid:int -> unit Import.Deferred.t
val fchown : Fd.t -> uid:int -> gid:int -> unit Import.Deferred.t
val access : string ->
[ `Exec | `Exists | `Read | `Write ] list ->
(unit, exn) Core.Std.Result.t Import.Deferred.t
val access_exn : string -> [ `Exec | `Exists | `Read | `Write ] list -> unit Import.Deferred.t
val set_close_on_exec : Fd.t -> unit
val clear_close_on_exec : Fd.t -> unit
val mkdir : ?p:unit -> ?perm:file_perm -> string -> unit Import.Deferred.t
val rmdir : string -> unit Import.Deferred.t
val chdir : string -> unit Import.Deferred.t
val getcwd : unit -> string Import.Deferred.t
val chroot : string -> unit Import.Deferred.t
type dir_handle = Core.Std.Unix.dir_handle
val opendir : string -> dir_handle Import.Deferred.t
val readdir : dir_handle -> string Import.Deferred.t
val rewinddir : dir_handle -> unit Import.Deferred.t
val closedir : dir_handle -> unit Import.Deferred.t
val pipe : Core.Std.Info.t ->
([ `Reader of Fd.t ] * [ `Writer of Fd.t ]) Import.Deferred.t
The info supplied to pipe is debugging information that will be included in the returned Fds.
val mkfifo : ?perm:file_perm -> string -> unit Import.Deferred.t
Create a named pipe with the given permissions.
val symlink : src:string -> dst:string -> unit Import.Deferred.t
val readlink : string -> string Import.Deferred.t
val mkstemp : string -> (string * Fd.t) Import.Deferred.t
mkstemp prefix creates and opens a unique temporary file with prefix, automatically appending a suffix of six random characters to make the name unique. Unlike C's mkstemp, prefix should not include six X's at the end. Raises Unix_error on errors.
val mkdtemp : string -> string Import.Deferred.t
type process_times = Core.Std.Unix.process_times = {
tms_utime : float;
User time for the process
tms_stime : float;
System time for the process
tms_cutime : float;
User time for the children processes
tms_cstime : float;
System time for the children processes
}
Time functions.
val times : unit -> process_times
type tm = Core.Std.Unix.tm = {
tm_sec : int;
Seconds 0..59
tm_min : int;
Minutes 0..59
tm_hour : int;
Hours 0..23
tm_mday : int;
Day of month 1..31
tm_mon : int;
Month of year 0..11
tm_year : int;
Year - 1900
tm_wday : int;
Day of week (Sunday is 0)
tm_yday : int;
Day of year 0..365
tm_isdst : bool;
Daylight time savings in effect
}
val time : unit -> float
val gettimeofday : unit -> float
val gmtime : float -> tm
val localtime : float -> tm
val mktime : tm -> float * tm
val utimes : string -> access:float -> modif:float -> unit Import.Deferred.t
val environment : unit -> string array
val getenv : string -> string option
val getenv_exn : string -> string
val putenv : key:string -> data:string -> unit
val unsetenv : string -> unit
val fork_exec : prog:string ->
args:string list ->
?use_path:bool ->
?env:string list -> unit -> Core.Std.Pid.t Import.Deferred.t
fork_exec ~prog ~args ?path ?env forks and execs prog with args, and returns the child pid. If use_path = true (the default) and prog doesn't contain a slash, then fork_exec searches the PATH environment variable for prog. If env is supplied, it is used as the environment when prog is executed.
type wait_on = [ `Any | `Group of Core.Std.Pid.t | `My_group | `Pid of Core.Std.Pid.t ]
val wait : wait_on -> (Core.Std.Pid.t * Exit_or_signal.t) Import.Deferred.t
val wait_nohang : wait_on -> (Core.Std.Pid.t * Exit_or_signal.t) option
val wait_untraced : wait_on -> (Core.Std.Pid.t * Exit_or_signal_or_stop.t) Import.Deferred.t
val wait_nohang_untraced : wait_on -> (Core.Std.Pid.t * Exit_or_signal_or_stop.t) option
val waitpid : Core.Std.Pid.t -> Exit_or_signal.t Import.Deferred.t
waitpid pid returns a deferred that becomes determined with the child's exit status, when the child process with process id pid exits. waitpid_exn is like waitpid, except the result only becomes determined if the child exits with status zero; it raises if the child terminates win any other way.
val waitpid_exn : Core.Std.Pid.t -> unit Import.Deferred.t
module Inet_addr : sig .. end
type t = Core.Std.Unix.Inet_addr.t
include Core.Std.Comparable.S with type t := t
same as Core.Unix
val of_string : string -> t
val to_string : t -> string
val bind_any : t
val bind_any_inet6 : t
val localhost : t
127.0.0.1
val localhost_inet6 : t
(::1)
val inet4_addr_of_int32 : Core.Std.Int32.t -> t
val inet4_addr_to_int32_exn : t -> Core.Std.Int32.t
val of_string_or_getbyname : string -> t Import.Deferred.t
of_string_or_getbyname hostname does a DNS lookup of hostname and returns the resulting IP address. The implemenation sequentializes all calls so that only a single call is active at a time. The is because we've observed thread safety issues with certain versions of winbind using "wins" name resolution.
val compare : t -> t -> int
val t_of_sexp : Sexplib.Sexp.t -> t
val sexp_of_t : t -> Sexplib.Sexp.t
val bin_t : t Core.Std.Bin_prot.Type_class.t
val bin_read_t : t Core.Std.Bin_prot.Read.reader
val __bin_read_t__ : (int -> t) Core.Std.Bin_prot.Read.reader
val bin_reader_t : t Core.Std.Bin_prot.Type_class.reader
val bin_size_t : t Core.Std.Bin_prot.Size.sizer
val bin_write_t : t Core.Std.Bin_prot.Write.writer
val bin_writer_t : t Core.Std.Bin_prot.Type_class.writer
module Cidr : module type of Core.Std.Unix.Cidr
module Protocol_family : sig .. end
val socketpair : unit -> Fd.t * Fd.t
module Socket : sig .. end
module Address : sig .. end
module Unix : sig .. end
type t = [ `Unix of string ]
val create : string -> t
val to_string : t -> string
val compare : t -> t -> int
val t_of_sexp : Sexplib.Sexp.t -> t
val __t_of_sexp__ : Sexplib.Sexp.t -> t
val sexp_of_t : t -> Sexplib.Sexp.t
val bin_t : t Core.Std.Bin_prot.Type_class.t
val bin_read_t : t Core.Std.Bin_prot.Read.reader
val __bin_read_t__ : (int -> t) Core.Std.Bin_prot.Read.reader
val bin_reader_t : t Core.Std.Bin_prot.Type_class.reader
val bin_size_t : t Core.Std.Bin_prot.Size.sizer
val bin_write_t : t Core.Std.Bin_prot.Write.writer
val bin_writer_t : t Core.Std.Bin_prot.Type_class.writer
module Inet : sig .. end
type t = [ `Inet of Inet_addr.t * int ]
val create : Inet_addr.t -> port:int -> t
val create_bind_any : port:int -> t
val addr : t -> Inet_addr.t
val port : t -> int
val to_string : t -> string
val to_host_and_port : t -> Core.Std.Host_and_port.t
val compare : t -> t -> int
val t_of_sexp : Sexplib.Sexp.t -> t
val __t_of_sexp__ : Sexplib.Sexp.t -> t
val sexp_of_t : t -> Sexplib.Sexp.t
val bin_t : t Core.Std.Bin_prot.Type_class.t
val bin_read_t : t Core.Std.Bin_prot.Read.reader
val __bin_read_t__ : (int -> t) Core.Std.Bin_prot.Read.reader
val bin_reader_t : t Core.Std.Bin_prot.Type_class.reader
val bin_size_t : t Core.Std.Bin_prot.Size.sizer
val bin_write_t : t Core.Std.Bin_prot.Write.writer
val bin_writer_t : t Core.Std.Bin_prot.Type_class.writer
type t = [ `Inet of Inet_addr.t * int | `Unix of string ]
val to_string : [< t ] -> string
val to_sockaddr : [< t ] -> Core.Std.Unix.sockaddr
val t_of_sexp : Sexplib.Sexp.t -> t
val __t_of_sexp__ : Sexplib.Sexp.t -> t
val sexp_of_t : t -> Sexplib.Sexp.t
val bin_t : t Core.Std.Bin_prot.Type_class.t
val bin_read_t : t Core.Std.Bin_prot.Read.reader
val __bin_read_t__ : (int -> t) Core.Std.Bin_prot.Read.reader
val bin_reader_t : t Core.Std.Bin_prot.Type_class.reader
val bin_size_t : t Core.Std.Bin_prot.Size.sizer
val bin_write_t : t Core.Std.Bin_prot.Write.writer
val bin_writer_t : t Core.Std.Bin_prot.Type_class.writer
module Family : sig .. end
type 'a t
val unix : Address.Unix.t t
val inet : Address.Inet.t t
val to_string : [< Address.t ] t -> string
type ('a, 'b) t
Sockets have a phantom type parameter that tracks the state of the socket in order to eliminate certain errors in which socket functions are called in the wrong order. Initially, a socket is `Unconnected. As various socket functions are called, they return a socket with a new phantom state. Here is a chart of the allowed state transitions.
        Unconnected ---connect--> Active
        |
        | ---bind--> Bound ---listen--> Passive ---accept---> Active
module Type : sig .. end
type 'a t
val tcp : Address.Inet.t t
val udp : Address.Inet.t t
val unix : Address.Unix.t t
val unix_dgram : Address.Unix.t t
val create : ([< Address.t ] as 'a) Type.t -> ([ `Unconnected ], 'a) t
val connect : ([ `Unconnected ], [< Address.t ] as 'a) t ->
'a -> ([ `Active ], 'a) t Import.Deferred.t
val connect_interruptible : ([ `Unconnected ], [< Address.t ] as 'a) t ->
'a ->
interrupt:unit Import.Deferred.t ->
[ `Interrupted | `Ok of ([ `Active ], 'a) t ] Import.Deferred.t
val bind : ([ `Unconnected ], [< Address.t ] as 'a) t ->
?reuseaddr:bool -> 'a -> ([ `Bound ], 'a) t Import.Deferred.t
bind socket addr sets close_on_exec for the fd of socket.
val listen : ?max_pending_connections:int ->
([ `Bound ], [< Address.t ] as 'a) t -> ([ `Passive ], 'a) t
val accept : ([ `Passive ], [< Address.t ] as 'a) t ->
[ `Ok of ([ `Active ], 'a) t * 'a | `Socket_closed ] Import.Deferred.t
val accept_interruptible : ([ `Passive ], [< Address.t ] as 'a) t ->
interrupt:unit Import.Deferred.t ->
[ `Interrupted | `Ok of ([ `Active ], 'a) t * 'a | `Socket_closed ]
Import.Deferred.t
val shutdown : ([< `Active | `Bound | `Passive | `Unconnected ], [< Address.t ]) t ->
[ `Both | `Receive | `Send ] -> unit
val fd : ([< `Active | `Bound | `Passive | `Unconnected ], [< Address.t ]) t -> Fd.t
val of_fd : Fd.t ->
([< Address.t ] as 'a) Type.t ->
([< `Active | `Bound | `Passive | `Unconnected ], 'a) t
val getsockname : ([< `Active | `Bound | `Passive | `Unconnected ], [< Address.t ] as 'a) t ->
'a
val getpeername : ([< `Active | `Bound | `Passive | `Unconnected ], [< Address.t ] as 'a) t ->
'a
module Opt : sig .. end
type 'a t
val debug : bool t
val broadcast : bool t
val reuseaddr : bool t
val keepalive : bool t
val dontroute : bool t
val oobinline : bool t
val acceptconn : bool t
val nodelay : bool t
val sndbuf : int t
val rcvbuf : int t
val error : int t
val typ : int t
val rcvlowat : int t
val sndlowat : int t
val linger : int option t
val rcvtimeo : float t
val sndtimeo : float t
val mcast_loop : bool t
val mcast_ttl : int t
val to_string : 'a t -> string
val getopt : ([< `Active | `Bound | `Passive | `Unconnected ], [< Address.t ]) t ->
'c Opt.t -> 'c
val setopt : ([< `Active | `Bound | `Passive | `Unconnected ], [< Address.t ]) t ->
'c Opt.t -> 'c -> unit
val mcast_join : ?ifname:string ->
?source:Inet_addr.t ->
([< `Active | `Bound | `Passive | `Unconnected ], [< Address.t ] as 'a) t ->
'a -> unit
val mcast_leave : ?ifname:string ->
([< `Active | `Bound | `Passive | `Unconnected ], [< Address.t ] as 'a) t ->
'a -> unit
val sexp_of_t : (([< `Active | `Bound | `Passive | `Unconnected ] as 'a) -> Sexplib.Sexp.t) ->
(([< Address.t ] as 'b) -> Sexplib.Sexp.t) -> ('a, 'b) t -> Sexplib.Sexp.t
module Host : sig .. end
type t = Core.Std.Unix.Host.t = {
name : string;
aliases : string array;
family : Protocol_family.t;
addresses : Inet_addr.t array;
}
val getbyname : string -> t option Import.Deferred.t
val getbyname_exn : string -> t Import.Deferred.t
val getbyaddr : Inet_addr.t -> t option Import.Deferred.t
val getbyaddr_exn : Inet_addr.t -> t Import.Deferred.t
val have_address_in_common : t -> t -> bool
val gethostname : unit -> string
val getuid : unit -> int
val geteuid : unit -> int
val getgid : unit -> int
val getegid : unit -> int
val setuid : int -> unit
type error = Core.Std.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 int
exception Unix_error of error * string * string
module Terminal_io : sig .. end
type t = Core.Std.Caml.Unix.terminal_io = {
mutable c_ignbrk : bool;
Ignore the break condition.
mutable c_brkint : bool;
Signal interrupt on break condition.
mutable c_ignpar : bool;
Ignore characters with parity errors.
mutable c_parmrk : bool;
Mark parity errors.
mutable c_inpck : bool;
Enable parity check on input.
mutable c_istrip : bool;
Strip 8th bit on input characters.
mutable c_inlcr : bool;
Map NL to CR on input.
mutable c_igncr : bool;
Ignore CR on input.
mutable c_icrnl : bool;
Map CR to NL on input.
mutable c_ixon : bool;
Recognize XON/XOFF characters on input.
mutable c_ixoff : bool;
Emit XON/XOFF chars to control input flow.
mutable c_opost : bool;
Enable output processing.
mutable c_obaud : int;
Output baud rate (0 means close connection).
mutable c_ibaud : int;
Input baud rate.
mutable c_csize : int;
Number of bits per character (5-8).
mutable c_cstopb : int;
Number of stop bits (1-2).
mutable c_cread : bool;
Reception is enabled.
mutable c_parenb : bool;
Enable parity generation and detection.
mutable c_parodd : bool;
Specify odd parity instead of even.
mutable c_hupcl : bool;
Hang up on last close.
mutable c_clocal : bool;
Ignore modem status lines.
mutable c_isig : bool;
Generate signal on INTR, QUIT, SUSP.
mutable c_icanon : bool;
Enable canonical processing (line buffering and editing)
mutable c_noflsh : bool;
Disable flush after INTR, QUIT, SUSP.
mutable c_echo : bool;
Echo input characters.
mutable c_echoe : bool;
Echo ERASE (to erase previous character).
mutable c_echok : bool;
Echo KILL (to erase the current line).
mutable c_echonl : bool;
Echo NL even if c_echo is not set.
mutable c_vintr : char;
Interrupt character (usually ctrl-C).
mutable c_vquit : char;
Quit character (usually ctrl-\).
mutable c_verase : char;
Erase character (usually DEL or ctrl-H).
mutable c_vkill : char;
Kill line character (usually ctrl-U).
mutable c_veof : char;
End-of-file character (usually ctrl-D).
mutable c_veol : char;
Alternate end-of-line char. (usually none).
mutable c_vmin : int;
Minimum number of characters to read before the read request is satisfied.
mutable c_vtime : int;
Maximum read wait (in 0.1s units).
mutable c_vstart : char;
Start character (usually ctrl-Q).
mutable c_vstop : char;
Stop character (usually ctrl-S).
}
type setattr_when = Core.Std.Caml.Unix.setattr_when = 
|TCSANOW
|TCSADRAIN
|TCSAFLUSH
val tcgetattr : Fd.t -> t Import.Deferred.t
val tcsetattr : t -> Fd.t -> mode:setattr_when -> unit Import.Deferred.t
module Passwd : sig .. end
Structure of entries in the passwd database.
type t = {
name : string;
passwd : string;
uid : int;
gid : int;
gecos : string;
dir : string;
shell : string;
}
val shell : t -> string
val dir : t -> string
val gecos : t -> string
val gid : t -> int
val uid : t -> int
val passwd : t -> string
val name : t -> string
module Fields : sig .. end
val names : string list
val shell : (t, string) Fieldslib.Field.t
val dir : (t, string) Fieldslib.Field.t
val gecos : (t, string) Fieldslib.Field.t
val gid : (t, int) Fieldslib.Field.t
val uid : (t, int) Fieldslib.Field.t
val passwd : (t, string) Fieldslib.Field.t
val name : (t, string) Fieldslib.Field.t
val fold : init:'acc__ ->
name:('acc__ -> (t, string) Fieldslib.Field.t -> 'acc__) ->
passwd:('acc__ -> (t, string) Fieldslib.Field.t -> 'acc__) ->
uid:('acc__ -> (t, int) Fieldslib.Field.t -> 'acc__) ->
gid:('acc__ -> (t, int) Fieldslib.Field.t -> 'acc__) ->
gecos:('acc__ -> (t, string) Fieldslib.Field.t -> 'acc__) ->
dir:('acc__ -> (t, string) Fieldslib.Field.t -> 'acc__) ->
shell:('acc__ -> (t, string) Fieldslib.Field.t -> 'acc__) -> 'acc__
val make_creator : name:((t, string) Fieldslib.Field.t ->
      'compile_acc__ -> ('input__ -> string) * 'compile_acc__) ->
passwd:((t, string) Fieldslib.Field.t ->
        'compile_acc__ -> ('input__ -> string) * 'compile_acc__) ->
uid:((t, int) Fieldslib.Field.t ->
     'compile_acc__ -> ('input__ -> int) * 'compile_acc__) ->
gid:((t, int) Fieldslib.Field.t ->
     'compile_acc__ -> ('input__ -> int) * 'compile_acc__) ->
gecos:((t, string) Fieldslib.Field.t ->
       'compile_acc__ -> ('input__ -> string) * 'compile_acc__) ->
dir:((t, string) Fieldslib.Field.t ->
     'compile_acc__ -> ('input__ -> string) * 'compile_acc__) ->
shell:((t, string) Fieldslib.Field.t ->
       'compile_acc__ -> ('input__ -> string) * 'compile_acc__) ->
'compile_acc__ -> ('input__ -> t) * 'compile_acc__
val create : name:string ->
passwd:string ->
uid:int -> gid:int -> gecos:string -> dir:string -> shell:string -> t
val map : name:((t, string) Fieldslib.Field.t -> string) ->
passwd:((t, string) Fieldslib.Field.t -> string) ->
uid:((t, int) Fieldslib.Field.t -> int) ->
gid:((t, int) Fieldslib.Field.t -> int) ->
gecos:((t, string) Fieldslib.Field.t -> string) ->
dir:((t, string) Fieldslib.Field.t -> string) ->
shell:((t, string) Fieldslib.Field.t -> string) -> t
val iter : name:((t, string) Fieldslib.Field.t -> unit) ->
passwd:((t, string) Fieldslib.Field.t -> unit) ->
uid:((t, int) Fieldslib.Field.t -> unit) ->
gid:((t, int) Fieldslib.Field.t -> unit) ->
gecos:((t, string) Fieldslib.Field.t -> unit) ->
dir:((t, string) Fieldslib.Field.t -> unit) ->
shell:((t, string) Fieldslib.Field.t -> unit) -> unit
val for_all : name:((t, string) Fieldslib.Field.t -> bool) ->
passwd:((t, string) Fieldslib.Field.t -> bool) ->
uid:((t, int) Fieldslib.Field.t -> bool) ->
gid:((t, int) Fieldslib.Field.t -> bool) ->
gecos:((t, string) Fieldslib.Field.t -> bool) ->
dir:((t, string) Fieldslib.Field.t -> bool) ->
shell:((t, string) Fieldslib.Field.t -> bool) -> bool
val exists : name:((t, string) Fieldslib.Field.t -> bool) ->
passwd:((t, string) Fieldslib.Field.t -> bool) ->
uid:((t, int) Fieldslib.Field.t -> bool) ->
gid:((t, int) Fieldslib.Field.t -> bool) ->
gecos:((t, string) Fieldslib.Field.t -> bool) ->
dir:((t, string) Fieldslib.Field.t -> bool) ->
shell:((t, string) Fieldslib.Field.t -> bool) -> bool
val to_list : name:((t, string) Fieldslib.Field.t -> 'elem__) ->
passwd:((t, string) Fieldslib.Field.t -> 'elem__) ->
uid:((t, int) Fieldslib.Field.t -> 'elem__) ->
gid:((t, int) Fieldslib.Field.t -> 'elem__) ->
gecos:((t, string) Fieldslib.Field.t -> 'elem__) ->
dir:((t, string) Fieldslib.Field.t -> 'elem__) ->
shell:((t, string) Fieldslib.Field.t -> 'elem__) -> 'elem__ list
val map_poly : ([< `Read | `Set_and_create ], t, 'x0) Fieldslib.Field.user -> 'x0 list
module Direct : sig .. end
val iter : t ->
name:((t, string) Fieldslib.Field.t -> t -> string -> unit) ->
passwd:((t, string) Fieldslib.Field.t -> t -> string -> unit) ->
uid:((t, int) Fieldslib.Field.t -> t -> int -> unit) ->
gid:((t, int) Fieldslib.Field.t -> t -> int -> unit) ->
gecos:((t, string) Fieldslib.Field.t -> t -> string -> unit) ->
dir:((t, string) Fieldslib.Field.t -> t -> string -> unit) ->
shell:((t, string) Fieldslib.Field.t -> t -> string -> unit) -> unit
val fold : t ->
init:'acc__ ->
name:('acc__ -> (t, string) Fieldslib.Field.t -> t -> string -> 'acc__) ->
passwd:('acc__ -> (t, string) Fieldslib.Field.t -> t -> string -> 'acc__) ->
uid:('acc__ -> (t, int) Fieldslib.Field.t -> t -> int -> 'acc__) ->
gid:('acc__ -> (t, int) Fieldslib.Field.t -> t -> int -> 'acc__) ->
gecos:('acc__ -> (t, string) Fieldslib.Field.t -> t -> string -> 'acc__) ->
dir:('acc__ -> (t, string) Fieldslib.Field.t -> t -> string -> 'acc__) ->
shell:('acc__ -> (t, string) Fieldslib.Field.t -> t -> string -> 'acc__) ->
'acc__
val getbyname : string -> t option Import.Deferred.t
val getbyname_exn : string -> t Import.Deferred.t
val getbyuid : int -> t option Import.Deferred.t
val getbyuid_exn : int -> t Import.Deferred.t
val t_of_sexp : Sexplib.Sexp.t -> t
val sexp_of_t : t -> Sexplib.Sexp.t
module Group : sig .. end
Structure of entries in the groups database.
type t = {
name : string;
passwd : string;
gid : int;
mem : string array;
}
val mem : t -> string array
val gid : t -> int
val passwd : t -> string
val name : t -> string
module Fields : sig .. end
val names : string list
val mem : (t, string array) Fieldslib.Field.t
val gid : (t, int) Fieldslib.Field.t
val passwd : (t, string) Fieldslib.Field.t
val name : (t, string) Fieldslib.Field.t
val fold : init:'acc__ ->
name:('acc__ -> (t, string) Fieldslib.Field.t -> 'acc__) ->
passwd:('acc__ -> (t, string) Fieldslib.Field.t -> 'acc__) ->
gid:('acc__ -> (t, int) Fieldslib.Field.t -> 'acc__) ->
mem:('acc__ -> (t, string array) Fieldslib.Field.t -> 'acc__) -> 'acc__
val make_creator : name:((t, string) Fieldslib.Field.t ->
      'compile_acc__ -> ('input__ -> string) * 'compile_acc__) ->
passwd:((t, string) Fieldslib.Field.t ->
        'compile_acc__ -> ('input__ -> string) * 'compile_acc__) ->
gid:((t, int) Fieldslib.Field.t ->
     'compile_acc__ -> ('input__ -> int) * 'compile_acc__) ->
mem:((t, string array) Fieldslib.Field.t ->
     'compile_acc__ -> ('input__ -> string array) * 'compile_acc__) ->
'compile_acc__ -> ('input__ -> t) * 'compile_acc__
val create : name:string -> passwd:string -> gid:int -> mem:string array -> t
val map : name:((t, string) Fieldslib.Field.t -> string) ->
passwd:((t, string) Fieldslib.Field.t -> string) ->
gid:((t, int) Fieldslib.Field.t -> int) ->
mem:((t, string array) Fieldslib.Field.t -> string array) -> t
val iter : name:((t, string) Fieldslib.Field.t -> unit) ->
passwd:((t, string) Fieldslib.Field.t -> unit) ->
gid:((t, int) Fieldslib.Field.t -> unit) ->
mem:((t, string array) Fieldslib.Field.t -> unit) -> unit
val for_all : name:((t, string) Fieldslib.Field.t -> bool) ->
passwd:((t, string) Fieldslib.Field.t -> bool) ->
gid:((t, int) Fieldslib.Field.t -> bool) ->
mem:((t, string array) Fieldslib.Field.t -> bool) -> bool
val exists : name:((t, string) Fieldslib.Field.t -> bool) ->
passwd:((t, string) Fieldslib.Field.t -> bool) ->
gid:((t, int) Fieldslib.Field.t -> bool) ->
mem:((t, string array) Fieldslib.Field.t -> bool) -> bool
val to_list : name:((t, string) Fieldslib.Field.t -> 'elem__) ->
passwd:((t, string) Fieldslib.Field.t -> 'elem__) ->
gid:((t, int) Fieldslib.Field.t -> 'elem__) ->
mem:((t, string array) Fieldslib.Field.t -> 'elem__) -> 'elem__ list
val map_poly : ([< `Read | `Set_and_create ], t, 'x0) Fieldslib.Field.user -> 'x0 list
module Direct : sig .. end
val iter : t ->
name:((t, string) Fieldslib.Field.t -> t -> string -> unit) ->
passwd:((t, string) Fieldslib.Field.t -> t -> string -> unit) ->
gid:((t, int) Fieldslib.Field.t -> t -> int -> unit) ->
mem:((t, string array) Fieldslib.Field.t -> t -> string array -> unit) ->
unit
val fold : t ->
init:'acc__ ->
name:('acc__ -> (t, string) Fieldslib.Field.t -> t -> string -> 'acc__) ->
passwd:('acc__ -> (t, string) Fieldslib.Field.t -> t -> string -> 'acc__) ->
gid:('acc__ -> (t, int) Fieldslib.Field.t -> t -> int -> 'acc__) ->
mem:('acc__ ->
     (t, string array) Fieldslib.Field.t -> t -> string array -> 'acc__) ->
'acc__
val getbyname : string -> t option Import.Deferred.t
val getbyname_exn : string -> t Import.Deferred.t
val getbygid : int -> t option Import.Deferred.t
val getbygid_exn : int -> t Import.Deferred.t
val t_of_sexp : Sexplib.Sexp.t -> t
val sexp_of_t : t -> Sexplib.Sexp.t
val getlogin : unit -> string Import.Deferred.t
Return the login name of the user executing the process.

This returns a deferred because the username may need to be looked up in what is essentially a database elsewhere on the network (winbound user, or NIS).

val wordexp : (?flags:[ `No_cmd | `Show_err | `Undef ] list ->
 string -> string array Import.Deferred.t)
Core.Std.Or_error.t
val wait_on_of_sexp : Sexplib.Sexp.t -> wait_on
val __wait_on_of_sexp__ : Sexplib.Sexp.t -> wait_on
val sexp_of_wait_on : wait_on -> Sexplib.Sexp.t
val error_of_sexp : Sexplib.Sexp.t -> error
val sexp_of_error : error -> Sexplib.Sexp.t