package eio_posix

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Low-level API for making POSIX calls directly.

This module provides an effects-based API for calling POSIX functions.

Normally it's better to use the cross-platform Eio APIs instead, which uses these functions automatically where appropriate.

These functions mostly copy the POSIX APIs directly, except that:

  1. They suspend the calling fiber instead of returning EAGAIN or similar.
  2. They handle EINTR by automatically restarting the call.
  3. They wrap Unix.file_descr in Fd, to avoid use-after-close bugs.
  4. They attach new FDs to switches, to avoid resource leaks.
type fd := Eio_unix.Fd.t
module Fd : sig ... end
val await_readable : fd -> unit
val await_writable : fd -> unit
val sleep_until : Mtime.t -> unit
val read : fd -> bytes -> int -> int -> int
val write : fd -> bytes -> int -> int -> int
val socket : sw:Eio.Std.Switch.t -> Unix.socket_domain -> Unix.socket_type -> int -> fd
val connect : fd -> Unix.sockaddr -> unit
val accept : sw:Eio.Std.Switch.t -> fd -> fd * Unix.sockaddr
val shutdown : fd -> Unix.shutdown_command -> unit
val recv_msg : fd -> Cstruct.t array -> Unix.sockaddr * int
val send_msg : fd -> ?dst:Unix.sockaddr -> Cstruct.t array -> int
val getrandom : Cstruct.t -> unit
val fstat : fd -> Unix.LargeFile.stats
val lstat : string -> Unix.LargeFile.stats
val realpath : string -> string
val mkdir : ?dirfd:fd -> mode:int -> string -> unit
val rename : ?old_dir:fd -> string -> ?new_dir:fd -> string -> unit
val readdir : string -> string array
val readv : fd -> Cstruct.t array -> int
val writev : fd -> Cstruct.t array -> int
val preadv : file_offset:Optint.Int63.t -> fd -> Cstruct.t array -> int
val pwritev : file_offset:Optint.Int63.t -> fd -> Cstruct.t array -> int
val pipe : sw:Eio.Std.Switch.t -> fd * fd
module Open_flags : sig ... end
val openat : ?dirfd:fd -> sw:Eio.Std.Switch.t -> mode:int -> string -> Open_flags.t -> fd

Note: the returned FD is always non-blocking and close-on-exec.

module Process : sig ... end
OCaml

Innovation. Community. Security.