package eio_posix

  1. Overview
  2. Docs

Module Eio_posix.Low_levelSource

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.
Sourcemodule Fd : sig ... end

A safe wrapper for Unix.file_descr.

Sourceval await_readable : Fd.t -> unit
Sourceval await_writable : Fd.t -> unit
Sourceval sleep_until : Mtime.t -> unit
Sourceval read : Fd.t -> bytes -> int -> int -> int
Sourceval write : Fd.t -> bytes -> int -> int -> int
Sourceval socket : sw:Eio.Std.Switch.t -> Unix.socket_domain -> Unix.socket_type -> int -> Fd.t
Sourceval connect : Fd.t -> Unix.sockaddr -> unit
Sourceval accept : sw:Eio.Std.Switch.t -> Fd.t -> Fd.t * Unix.sockaddr
Sourceval shutdown : Fd.t -> Unix.shutdown_command -> unit
Sourceval recv_msg : Fd.t -> bytes -> int * Unix.sockaddr
Sourceval send_msg : Fd.t -> dst:Unix.sockaddr -> bytes -> int
Sourceval getrandom : Cstruct.t -> unit
Sourceval fstat : Fd.t -> Unix.LargeFile.stats
Sourceval lstat : string -> Unix.LargeFile.stats
Sourceval realpath : string -> string
Sourceval mkdir : ?dirfd:Fd.t -> mode:int -> string -> unit
Sourceval rename : ?old_dir:Fd.t -> string -> ?new_dir:Fd.t -> string -> unit
Sourceval readdir : string -> string array
Sourceval readv : Fd.t -> Cstruct.t array -> int
Sourceval writev : Fd.t -> Cstruct.t array -> int
Sourceval preadv : file_offset:Optint.Int63.t -> Fd.t -> Cstruct.t array -> int
Sourceval pwritev : file_offset:Optint.Int63.t -> Fd.t -> Cstruct.t array -> int
Sourceval pipe : sw:Eio.Std.Switch.t -> Fd.t * Fd.t
Sourcemodule Open_flags : sig ... end
Sourceval openat : ?dirfd:Fd.t -> sw:Eio.Std.Switch.t -> mode:int -> string -> Open_flags.t -> Fd.t

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

Sourcemodule Process : sig ... end