Module Async_unix.Unix
module Fd = Fdinclude Async_unix__.Unix_syscalls
module Syscall_result = Core.Unix.Syscall_resultmodule Exit = Core.Unix.Exitmodule Exit_or_signal = Core.Unix.Exit_or_signalmodule Exit_or_signal_or_stop = Core.Unix.Exit_or_signal_or_stopval system : string -> Exit_or_signal.t Async_unix__.Import.Deferred.tval system_exn : string -> unit Async_unix__.Import.Deferred.tval getpid : unit -> Core.Pid.tval getppid : unit -> Core.Pid.t optionval getppid_exn : unit -> Core.Pid.tval this_process_became_child_of_init : ?poll_delay:Core.Time.Span.t -> unit -> unit Async_unix__.Import.Deferred.tthis_process_became_child_of_initreturns a deferred that becomes determined when the current process becomes a child ofinit(8). This is useful for determining whether one's parent has died, because in that caseinitwill become one's parent.See
Linux_ext.pr_set_pdeathsig : Signal.t -> unitfor a related way to get information about parent death.?poll_delaycontrols how often to check.
val nice : int -> intval cores : (unit -> int Async_unix__.Import.Deferred.t) Core.Or_error.tcores ()Returns the number of cores.
type open_flag=[|`Rdonly|`Wronly|`Rdwr|`Nonblock|`Append|`Creat|`Trunc|`Excl|`Noctty|`Dsync|`Sync|`Rsync]type file_perm= int
val openfile : ?perm:file_perm -> string -> mode:open_flag list -> Fd.t Async_unix__.Import.Deferred.t
module Lock_mode = Async_unix__.Unix_syscalls.Lock_modemodule Lock_mechanism = Async_unix__.Unix_syscalls.Lock_mechanismmodule Lock = Async_unix__.Unix_syscalls.Lockval with_file : ?lock:Lock.t -> ?perm:file_perm -> string -> mode:open_flag list -> f:(Fd.t -> 'a Async_unix__.Import.Deferred.t) -> 'a Async_unix__.Import.Deferred.twith_file file ~mode ~perm ~fopensfile, and appliesfto the resulting file descriptor. When the result offbecomes determined, it closes the descriptor and returns the result off.If
lockis supplied, then the file descriptor is locked before callingfwith the specifiedlock_mechanism. Note that it is not unlocked before close, which might be significant if this file descriptior is held elsewhere (e.g., by fork() or dup()).
module Open_flags = Core.Unix.Open_flagsval fcntl_getfl : Fd.t -> Open_flags.t Async_unix__.Import.Deferred.tfcntl_getflandfcntl_setfare deferred wrappers around the corresponding functions inCore.Unixfor accessing the open-file-descriptor table.
val fcntl_setfl : Fd.t -> Open_flags.t -> unit Async_unix__.Import.Deferred.t
include module type of Fd.Close
type socket_handling=|Shutdown_socket|Do_not_shutdown_sockettype file_descriptor_handling=|Close_file_descriptor of socket_handling|Do_not_close_file_descriptor
val close : ?file_descriptor_handling:file_descriptor_handling -> Fd.t -> unit Async_unix__.Import.Deferred.tclose tprevents further use oft, and makesshutdown()andclose()system calls ont's underlying file descriptor according to thefile_descriptor_handlingargument and whether or nottis a socket, i.e.,kind t = Socket `Active:| file_descriptor_handling | shutdown() | close() | |----------------------------------------------+------------+---------| | Do_not_close_file_descriptor | no | no | | Close_file_descriptor Shutdown_socket | if socket | yes | | Close_file_descriptor Do_not_shutdown_socket | no | yes |The result of
closebecomes determined once the system calls complete. It is OK to callclosemultiple times on the samet; calls subsequent to the initial call will have no effect, but will return the same deferred as the original call.
val lseek : Fd.t -> int64 -> mode:[< `Set | `Cur | `End ] -> int64 Async_unix__.Import.Deferred.tval truncate : string -> len:int64 -> unit Async_unix__.Import.Deferred.tval ftruncate : Fd.t -> len:int64 -> unit Async_unix__.Import.Deferred.tval fsync : Fd.t -> unit Async_unix__.Import.Deferred.tval fdatasync : Fd.t -> unit Async_unix__.Import.Deferred.tval sync : unit -> unit Async_unix__.Import.Deferred.tval lockf : ?len:Core.Int64.t -> Fd.t -> Lock_mode.t -> unit Async_unix__.Import.Deferred.tlockf fd lock_mode ?lenlocks the section of the open filefdspecified by the current file position andlen(see man lockf). It returns when the lock has been acquired. It raises iffdis closed.Note that, despite the name, this function does not call the UNIX lockf() system call; rather it calls fcntl() with F_SETLKW
val try_lockf : ?len:Core.Int64.t -> Fd.t -> Lock_mode.t -> booltry_lockf fd lock_mode ?lenattempts to lock the section of the open filefdspecified by the current file position andlen(see man lockf). It returnstrueif it acquired the lock. It raises iffdis closed.Note that, despite the name, this function does not call the UNIX lockf() system call; rather it calls fcntl() with F_SETLK
val test_lockf : ?len:Core.Int64.t -> Fd.t -> booltest_lockf fd ?lenchecks the lock on section of the open filefdspecified by the current file position andlen. If the section is unlocked or locked by this process, it returns true, else it returns false. It raises iffdis closed.Note that, despite the name, this function does not call the UNIX lockf() system call; rather it calls fcntl() with F_GETLK
val unlockf : ?len:Core.Int64.t -> Fd.t -> unitunlockf fd ?lenunlocks the section of the open filefdspecified by the current file position andlen. It raises iffdis closed.Note that, despite the name, this function does not call the UNIX lockf() system call; rather it calls fcntl() with F_UNLCK
val flock : Fd.t -> Lock_mode.t -> unit Async_unix__.Import.Deferred.tflock fd lock_modelocks the open filefd(see man 2 flock). It returns when the lock has been acquired. It raises iffdis closed.
val try_flock : Fd.t -> Lock_mode.t -> booltry_flock fd lock_modeattempts to lock the open filefd(see man 2 flock). It returnstrueif it acquired the lock orfalseif a conflicting lock was already present. It raises iffdis closed.
val funlock : Fd.t -> unitfunlock fdunlocks the open filefd(seeman 2 flock). It raises iffdis closed.
module File_kind = Async_unix__.Unix_syscalls.File_kindmodule Stats = Async_unix__.Unix_syscalls.Statsval fstat : Fd.t -> Stats.t Async_unix__.Import.Deferred.tval stat : string -> Stats.t Async_unix__.Import.Deferred.tval lstat : string -> Stats.t Async_unix__.Import.Deferred.tval isatty : Fd.t -> bool Async_unix__.Import.Deferred.tval unlink : string -> unit Async_unix__.Import.Deferred.tval remove : string -> unit Async_unix__.Import.Deferred.tval rename : src:string -> dst:string -> unit Async_unix__.Import.Deferred.tval link : ?force:bool -> target:string -> link_name:string -> unit -> unit Async_unix__.Import.Deferred.tval chmod : string -> perm:file_perm -> unit Async_unix__.Import.Deferred.tval fchmod : Fd.t -> perm:file_perm -> unit Async_unix__.Import.Deferred.tval chown : string -> uid:int -> gid:int -> unit Async_unix__.Import.Deferred.tval fchown : Fd.t -> uid:int -> gid:int -> unit Async_unix__.Import.Deferred.tval access : string -> [ `Read | `Write | `Exec | `Exists ] list -> (unit, exn) Core.Result.t Async_unix__.Import.Deferred.tval access_exn : string -> [ `Read | `Write | `Exec | `Exists ] list -> unit Async_unix__.Import.Deferred.tval set_close_on_exec : Fd.t -> unitval clear_close_on_exec : Fd.t -> unitval mkdir : ?p:unit -> ?perm:file_perm -> string -> unit Async_unix__.Import.Deferred.tval rmdir : string -> unit Async_unix__.Import.Deferred.tval chdir : string -> unit Async_unix__.Import.Deferred.tval getcwd : unit -> string Async_unix__.Import.Deferred.tval chroot : string -> unit Async_unix__.Import.Deferred.t
type dir_handle= Core.Unix.dir_handle
val opendir : string -> dir_handle Async_unix__.Import.Deferred.tval readdir_opt : dir_handle -> string option Async_unix__.Import.Deferred.treaddir_opt dir_handlereturns the next directory member, orNonewhen there are no more directory members to return.
val rewinddir : dir_handle -> unit Async_unix__.Import.Deferred.tval closedir : dir_handle -> unit Async_unix__.Import.Deferred.tval pipe : Core.Info.t -> ([ `Reader of Fd.t ] * [ `Writer of Fd.t ]) Async_unix__.Import.Deferred.tThe
infosupplied to pipe is debugging information that will be included in the returnedFds.
val mkfifo : ?perm:file_perm -> string -> unit Async_unix__.Import.Deferred.tCreate a named pipe with the given permissions.
val symlink : target:string -> link_name:string -> unit Async_unix__.Import.Deferred.tval readlink : string -> string Async_unix__.Import.Deferred.tval mkstemp : string -> (string * Fd.t) Async_unix__.Import.Deferred.tmkstemp prefixcreates and opens a unique temporary file withprefix, automatically appending a suffix of six random characters to make the name unique. Unlike C'smkstemp,prefixshould not include six X's at the end.- raises Unix_error
on errors.
val mkdtemp : string -> string Async_unix__.Import.Deferred.tval getgrouplist : string -> int -> int array Async_unix__.Import.Deferred.t
type process_times= Core.Unix.process_times={}Time functions.
val times : unit -> process_times
type tm= Core.Unix.tm={}
val time : unit -> floatval gettimeofday : unit -> floatval gmtime : float -> tmval localtime : float -> tmval mktime : tm -> float * tmval utimes : string -> access:float -> modif:float -> unit Async_unix__.Import.Deferred.t
type env= Core.Unix.env
val sexp_of_env : env -> Ppx_sexp_conv_lib.Sexp.tval env_of_sexp : Ppx_sexp_conv_lib.Sexp.t -> env
val environment : unit -> string arrayval getenv : string -> string optionval getenv_exn : string -> stringval unsafe_getenv : string -> string optionval unsafe_getenv_exn : string -> stringval putenv : key:string -> data:string -> unitval unsetenv : string -> unitval fork_exec : prog:string -> argv:string list -> ?use_path:bool -> ?env:[ env | `Replace_raw of string list ] -> unit -> Core.Pid.t Async_unix__.Import.Deferred.tfork_exec ~prog ~argv ?path ?envforks and execsprogwithargv, and returns the child pid. Ifuse_path = true(the default) andprogdoesn't contain a slash, thenfork_execsearches the PATH environment variable forprog. Ifenvis supplied, it specifies the environment whenprogis executed.If
envcontains multiple bindings for the same variable, the last takes precedence. In the case of`Extend, bindings inenvtake precedence over the existing environment. SeeUnix.exec.
type wait_on=[|`Any|`Group of Core.Pid.t|`My_group|`Pid of Core.Pid.t]
val sexp_of_wait_on : wait_on -> Ppx_sexp_conv_lib.Sexp.tval wait_on_of_sexp : Ppx_sexp_conv_lib.Sexp.t -> wait_onval __wait_on_of_sexp__ : Ppx_sexp_conv_lib.Sexp.t -> wait_on
val wait : wait_on -> (Core.Pid.t * Exit_or_signal.t) Async_unix__.Import.Deferred.tval wait_nohang : wait_on -> (Core.Pid.t * Exit_or_signal.t) optionval wait_untraced : wait_on -> (Core.Pid.t * Exit_or_signal_or_stop.t) Async_unix__.Import.Deferred.tval wait_nohang_untraced : wait_on -> (Core.Pid.t * Exit_or_signal_or_stop.t) optionval waitpid : Core.Pid.t -> Exit_or_signal.t Async_unix__.Import.Deferred.twaitpid pidreturns a deferred that becomes determined with the child's exit status, when the child process with process idpidexits.waitpid_exnis likewaitpid, except the result only becomes determined if the child exits with status zero; it raises if the child terminates in any other way.
val waitpid_prompt : Core.Pid.t -> Exit_or_signal.t Async_unix__.Import.Deferred.tSame as
waitpid, but guarantees that the resultingDeferredis determined in the same async job as thewaitsystem call, so that it's safe to keep using thepidif the deferred is not determined.
val waitpid_exn : Core.Pid.t -> unit Async_unix__.Import.Deferred.t
module Inet_addr = Async_unix__.Unix_syscalls.Inet_addrmodule Cidr = Core.Unix.Cidrmodule Protocol_family = Async_unix__.Unix_syscalls.Protocol_familymodule Socket = Async_unix__.Unix_syscalls.Socketval bind_to_interface_exn : (Fd.t -> Linux_ext.Bound_to_interface.t -> unit) Core.Or_error.t
module Host = Async_unix__.Unix_syscalls.Hosttype socket_domain= Core.Unix.socket_domain=|PF_UNIX|PF_INET|PF_INET6
val bin_shape_socket_domain : Bin_prot.Shape.tval bin_size_socket_domain : socket_domain Bin_prot.Size.sizerval bin_write_socket_domain : socket_domain Bin_prot.Write.writerval bin_writer_socket_domain : socket_domain Bin_prot.Type_class.writerval bin_read_socket_domain : socket_domain Bin_prot.Read.readerval __bin_read_socket_domain__ : (int -> socket_domain) Bin_prot.Read.readerval bin_reader_socket_domain : socket_domain Bin_prot.Type_class.readerval bin_socket_domain : socket_domain Bin_prot.Type_class.tval compare_socket_domain : socket_domain -> socket_domain -> intval hash_fold_socket_domain : Base.Hash.state -> socket_domain -> Base.Hash.stateval hash_socket_domain : socket_domain -> Base.Hash.hash_valueval sexp_of_socket_domain : socket_domain -> Ppx_sexp_conv_lib.Sexp.tval socket_domain_of_sexp : Ppx_sexp_conv_lib.Sexp.t -> socket_domain
type socket_type= Core.Unix.socket_type=|SOCK_STREAM|SOCK_DGRAM|SOCK_RAW|SOCK_SEQPACKET
val bin_shape_socket_type : Bin_prot.Shape.tval bin_size_socket_type : socket_type Bin_prot.Size.sizerval bin_write_socket_type : socket_type Bin_prot.Write.writerval bin_writer_socket_type : socket_type Bin_prot.Type_class.writerval bin_read_socket_type : socket_type Bin_prot.Read.readerval __bin_read_socket_type__ : (int -> socket_type) Bin_prot.Read.readerval bin_reader_socket_type : socket_type Bin_prot.Type_class.readerval bin_socket_type : socket_type Bin_prot.Type_class.tval compare_socket_type : socket_type -> socket_type -> intval hash_fold_socket_type : Base.Hash.state -> socket_type -> Base.Hash.stateval hash_socket_type : socket_type -> Base.Hash.hash_valueval sexp_of_socket_type : socket_type -> Ppx_sexp_conv_lib.Sexp.tval socket_type_of_sexp : Ppx_sexp_conv_lib.Sexp.t -> socket_type
type sockaddr= Core.Unix.sockaddr=|ADDR_UNIX of string|ADDR_INET of Inet_addr.t * int
val bin_shape_sockaddr : Bin_prot.Shape.tval bin_size_sockaddr : sockaddr Bin_prot.Size.sizerval bin_write_sockaddr : sockaddr Bin_prot.Write.writerval bin_writer_sockaddr : sockaddr Bin_prot.Type_class.writerval bin_read_sockaddr : sockaddr Bin_prot.Read.readerval __bin_read_sockaddr__ : (int -> sockaddr) Bin_prot.Read.readerval bin_reader_sockaddr : sockaddr Bin_prot.Type_class.readerval bin_sockaddr : sockaddr Bin_prot.Type_class.tval compare_sockaddr : sockaddr -> sockaddr -> intval sexp_of_sockaddr : sockaddr -> Ppx_sexp_conv_lib.Sexp.t
type sockaddr_blocking_sexp= sockaddrsockaddr_blocking_sexpis likesockaddr, withof_sexpthat performs DNS lookup to resolveInet_addr.t.
val bin_shape_sockaddr_blocking_sexp : Bin_prot.Shape.tval bin_size_sockaddr_blocking_sexp : sockaddr_blocking_sexp Bin_prot.Size.sizerval bin_write_sockaddr_blocking_sexp : sockaddr_blocking_sexp Bin_prot.Write.writerval bin_writer_sockaddr_blocking_sexp : sockaddr_blocking_sexp Bin_prot.Type_class.writerval bin_read_sockaddr_blocking_sexp : sockaddr_blocking_sexp Bin_prot.Read.readerval __bin_read_sockaddr_blocking_sexp__ : (int -> sockaddr_blocking_sexp) Bin_prot.Read.readerval bin_reader_sockaddr_blocking_sexp : sockaddr_blocking_sexp Bin_prot.Type_class.readerval bin_sockaddr_blocking_sexp : sockaddr_blocking_sexp Bin_prot.Type_class.tval sexp_of_sockaddr_blocking_sexp : sockaddr_blocking_sexp -> Ppx_sexp_conv_lib.Sexp.tval sockaddr_blocking_sexp_of_sexp : Ppx_sexp_conv_lib.Sexp.t -> sockaddr_blocking_sexp
module Addr_info = Async_unix__.Unix_syscalls.Addr_infomodule Name_info = Async_unix__.Unix_syscalls.Name_infoval gethostname : unit -> stringval getuid : unit -> intval geteuid : unit -> intval getgid : unit -> intval getegid : unit -> intval setuid : int -> unit
module Error = Core.Unix.ErrorexceptionUnix_error of Error.t * string * string
module Terminal_io = Async_unix__.Unix_syscalls.Terminal_iomodule Passwd = Async_unix__.Unix_syscalls.PasswdStructure of entries in the
passwddatabase.
module Group = Async_unix__.Unix_syscalls.GroupStructure of entries in the
groupsdatabase.
module Ifaddr = Core.Unix.Ifaddrval getifaddrs : unit -> Ifaddr.t list Async_unix__.Import.Deferred.tGets the information using the socket-based netlink interface, which can block; see https://www.infradead.org/~tgr/libnl/doc/core.html.
val getlogin : unit -> string Async_unix__.Import.Deferred.tReturns 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 Async_unix__.Import.Deferred.t) Core.Or_error.t
module Private = Async_unix__.Unix_syscalls.Private