package eio_linux

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

Wrap Unix.file_descr to track whether it has been closed.

type t

Either a Unix.file_descr or nothing (if closed) .

val is_open : t -> bool

is_open t is true if close hasn't been called yet.

val close : t -> unit

close t closes t.

  • raises Invalid_arg

    if t is already closed.

val of_unix : sw:Eio.Std.Switch.t -> seekable:bool -> close_unix:bool -> Unix.file_descr -> t

let t = of_unix ~sw ~seekable ~close_unix fd wraps fd as an open file descriptor. This is unsafe if fd is closed directly (before or after wrapping it).

  • parameter sw

    t is closed when sw is released, if not closed manually first.

  • parameter close_unix

    If true, closing t also closes fd. If false, the caller is responsible for closing fd, which must not happen until after t is closed.

  • parameter seekable

    If true, we pass -1 to io_uring as the "file offset", to use the current offset. If false, pass 0 as the file offset, which is needed for sockets.

val to_unix : [< `Peek | `Take ] -> t -> Unix.file_descr

to_unix op t returns the wrapped descriptor. This allows unsafe access to the FD. If op is `Take then t is marked as closed (but the underlying FD is not actually closed).

  • raises Invalid_arg

    if t is closed.