Module Posix_uname

POSIX system identification bindings.

This module provides OCaml bindings to the POSIX uname function defined in sys/utsname.h.

It allows retrieval of system identification information such as the operating system name, version, and hardware architecture.

type utsname = {
  1. sysname : string;
    (*

    Operating system name (e.g., "Linux", "Darwin")

    *)
  2. nodename : string;
    (*

    Network node hostname

    *)
  3. release : string;
    (*

    Operating system release (e.g., "5.4.0")

    *)
  4. version : string;
    (*

    Operating system version

    *)
  5. machine : string;
    (*

    Hardware architecture (e.g., "x86_64", "arm64")

    *)
}

System identification information returned by uname.

This record corresponds to the POSIX struct utsname.

val uname : unit -> utsname

Return system identification information.

See uname(2).

  • returns

    A record containing system identification information.

  • raises Unix.Unix_error

    on failure.

Example:

  let info = uname () in
  Printf.printf "Running on %s %s (%s)\n" info.sysname info.release
    info.machine