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 recv_msg_with_fds : sw:Eio.Std.Switch.t -> max_fds:int -> fd -> Cstruct.t array -> Unix.sockaddr * int * fd list
Sourceval send_msg : fd -> ?fds:fd list -> ?dst:Unix.sockaddr -> Cstruct.t array -> int
Sourceval getrandom : Cstruct.t -> unit
Sourceval lseek : fd -> Optint.Int63.t -> [ `Set | `Cur | `End ] -> Optint.Int63.t
Sourceval fsync : fd -> unit
Sourceval ftruncate : fd -> Optint.Int63.t -> unit
Sourcetype stat
Sourceval create_stat : unit -> stat
Sourceval fstat : buf:stat -> fd -> unit
Sourceval fstatat : buf:stat -> ?dirfd:fd -> follow:bool -> string -> unit
Sourceval blksize : stat -> int64
Sourceval uid : stat -> int64
Sourceval gid : stat -> int64
Sourceval ino : stat -> int64
Sourceval size : stat -> int64
Sourceval rdev : stat -> int64
Sourceval dev : stat -> int64
Sourceval perm : stat -> int
Sourceval mode : stat -> int
Sourceval atime_sec : stat -> int64
Sourceval ctime_sec : stat -> int64
Sourceval mtime_sec : stat -> int64
Sourceval atime_nsec : stat -> int
Sourceval ctime_nsec : stat -> int
Sourceval mtime_nsec : stat -> int
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.