Module More.Os

Operating system interaction.

File system

module Path : sig ... end

File system path operations.

module File : sig ... end

Regular file operations.

module Dir : sig ... end

Directory operations.

File descriptors and sockets

module Fd : sig ... end

File descriptors operations.

module Socket : sig ... end

Socket operations.

Processes

module Env : sig ... end

Environment variables.

module Cmd : sig ... end

Executing commands.

module Exit : sig ... end

Program exit.

Sleeping and timing

val sleep : Mtime.Span.t -> Mtime.Span.t

sleep dur sleeps for duration dur and returns the duration slept. The latter may be smaller than dur if the call was interrupted by a signal. This becomes imprecise if dur is greater than ~104 days.

val relax : unit -> unit

relax sleeps for a very small duration. Can be used for relaxed busy waiting.

module Cpu : sig ... end

CPU time and information.

module Mtime : sig ... end

Monotonic time clock and sleep.

Name, version and architecture

module Name : sig ... end

OS names.

val name : ?id_like:bool -> unit -> Name.t

name () is the name of the operating system running the process. If id_like is true returns a possible parent name instead (e.g. "debian" instead of "ubuntu"), defaults to false. This is determined, along with version as follows:

  • On POSIX environments it depends on the lowercased sysname field returned by uname(2):

    • "linux", the file /etc/os-release is consulted. The lowercased ID or first element of ID_LIKE if id_like is true determines id and Name.Linux id is returned. The field VERSION_ID is used to determine version. If the file can't be found id is sysname and version "unknown".
    • "freebsd", behaves like the Linux case but Bsd id is returned.
    • "darwin", the file /System/Library/CoreServices/SystemVersion.plist is consulted. The lowercased ProductName key determines id and Name.Darwin id is returned. The ProductVersion key determines version. If the file can't be found id is sysname and version "unknown".
    • "netbsd" and "openbsd" then Name.Bsd sysname is returned and version is "unknown".
    • Starts with "cygwin_nt", then Name.Windows "cygwin" and version is determined like windows (see below).
    • Otherwise it returns Other sysname and version is "unknown"
  • On Windows this returns Windows "windows" and version uses the the caml_win32_* variables of the OCaml runtime system to format a version number
  • Otherwise it uses Name.Other "unknown" and version is "unknown"
val version : unit -> string

version () is a version string for the operating system. The format and determination depends on name, read there. If no version can be determined this is "unknown".

module Arch : sig ... end

OS architectures.

val arch : unit -> Arch.t

arch () is the architecture of the operating system running the process (it may differ from your CPU). It is determined by calling Arch.of_string with a string obtained as follows.

  • On POSIX environments it uses the machine field returned by uname(2).
  • On Windows it uses the GetNativeSystemInfo function and munges the wProcessorArchitecture field into a string.
  • Otherwise it uses "unknown".

Bazaar

val exn_don't_catch : exn -> bool

exn_don't_cath exn is true iff exn is Stack_overflow, Out_of_memory or Sys.Break.

FIXME find a place for that.