package devkit

  1. Overview
  2. Docs

*nix support

val log : Log.logger
val fork : unit -> [> `Child | `Forked of int ]
val unparent : unit -> unit

fork off and die

val daemonize : unit -> unit
val write_pidfile : string -> unit
val read_pidfile : string -> int
val probe_pidfile : string -> [> `Alive of int | `Error of exn | `Missing | `Stale ]
val check_pidfile : string -> unit
val manage_pidfile : string -> unit
val restart : ('a -> 'b) -> 'a -> 'b
val handle_sig_exit_with : exit:bool -> (unit -> unit) -> unit

NB be careful with mutexes in signal handlers. Outputting anything to ocaml channels is a potential deadlock. Use signalfd which invokes signal handlers in predictable context.

  • deprecated

    easy to deadlock, use signalfd instead

val handle_sig_reload_with : (unit -> unit) -> unit
  • deprecated

    easy to deadlock, use signalfd instead

val show_addr : Unix.sockaddr -> string
val get_inet_addr_exn : Unix.sockaddr -> Unix.inet_addr
val show_inet_addr_exn : Unix.sockaddr -> string
val make_inet_addr_exn : string -> int -> Unix.sockaddr
val inet_addr_of_string : string -> Unix.sockaddr
val unix_addr_of_string : string -> Unix.sockaddr
val parse_addr_port_exn : string -> string * int
val parse_ip_port_exn : string -> Unix.inet_addr * int

Parse input as ip:port

  • returns

    a tuple representing ip and port

val sockaddr_of_string : string -> Unix.sockaddr

Convert a string to a Unix.sockaddr.

Formats supported are:

  • unix:file_path
  • host:port
  • *:port, using Unix.inet_addr_any
  • port, using Unix.inet_addr_loopback
val read_process : string -> string

Execute process and capture stdout to string,

  • returns

    empty string on error

module Ev = Libevent
val output_process_exit : string -> Unix.process_status IO.output
  • returns

    IO.t to feed stdin of spawned process

val output_process : string -> unit IO.output
  • returns

    IO.t to feed stdin of spawned process

val write_process_exn : string -> ExtBytes.Bytes.t -> unit
val write_process : string -> ExtBytes.Bytes.t -> bool
val mounts : unit -> (string * string * string list) list
val find_mount : string -> string * string * string list
  • parameter path

    must be normalized

val sleep : float -> unit
val output_buf_fd : ?bufsize:int -> Unix.file_descr -> unit IO.output

Buffered output to Unix.file_descr. Doesn't own the file descriptor.

val unlimit_soft : Devkit_core.Prelude.U.resource -> unit
val raise_limits : unit -> unit

raise core and nofile soft limits (to the corresponding hard limits)

val connect : Unix.file_descr -> Unix.sockaddr -> unit
val connect_lwt : Lwt_unix.file_descr -> Lwt_unix.sockaddr -> unit Lwt.t
val get_xdg_dir : env:string -> string -> string
val xdg_cache_dir : string lazy_t
val xdg_config_dir : string lazy_t
val quote_if_needed : string -> string
val args : string list
val cmdline : string
OCaml

Innovation. Community. Security.