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

Sourcemodule Process : sig ... end
OCaml

Innovation. Community. Security.