module Misc:sig
..end
This section contains miscellaneous functions that don't really belong in any other section.
type
timeval = {
|
sec : |
|
usec : |
type
rusage = {
|
utime : |
(* | user CPU time used | *) |
|
stime : |
(* | system CPU time used | *) |
|
maxrss : |
(* | maximum resident set size | *) |
|
ixrss : |
(* | integral shared memory size (X) | *) |
|
idrss : |
(* | integral unshared data size (X) | *) |
|
isrss : |
(* | integral unshared stack size (X) | *) |
|
minflt : |
(* | page reclaims (soft page faults) (X) | *) |
|
majflt : |
(* | page faults (hard page faults) | *) |
|
nswap : |
(* | swaps (X) | *) |
|
inblock : |
(* | block input operations | *) |
|
outblock : |
(* | block output operations | *) |
|
msgsnd : |
(* | IPC messages sent (X) | *) |
|
msgrcv : |
(* | IPC messages received (X) | *) |
|
nsignals : |
(* | signals received (X) | *) |
|
nvcsw : |
(* | voluntary context switches (X) | *) |
|
nivcsw : |
(* | involuntary context switches (X) | *) |
Data type for resource usage results. Members marked with (X) are unsupported on Windows.
type
cpu_times = {
|
user : |
|
nice : |
|
sys : |
|
idle : |
|
irq : |
type
cpu_info = {
|
model : |
|
speed : |
|
cpu_times : |
Data type for CPU information
type
interface_address = {
|
name : |
|
phys_addr : |
|
is_internal : |
|
address : |
|
netmask : |
Data type for interface addresses.
type
handle_type =
| |
File |
| |
Tty |
| |
Pipe |
| |
Tcp |
| |
Udp |
| |
Unknown |
val guess_handle : Unix.file_descr -> handle_type
Used to detect what type of stream should be used with a given file descriptor. Usually this will be used during initialization to guess the type of the stdio streams.
For isatty(3) equivalent functionality use this function and test for UV_TTY.
val resident_set_memory : unit -> int64 Uwt_base.uv_result
Gets the resident set size (RSS) for the current process.
val resident_set_memory_exn : unit -> int64
val uptime : unit -> float Uwt_base.uv_result
Gets the current system uptime.
val uptime_exn : unit -> float
val getrusage : unit -> rusage Uwt_base.uv_result
Gets the resource usage measures for the current process. On Windows not all fields are set
val getrusage_exn : unit -> rusage
val cpu_info : unit -> cpu_info array Uwt_base.uv_result
Gets information about the CPUs on the system.
val cpu_info_exn : unit -> cpu_info array
val interface_addresses : unit -> interface_address array Uwt_base.uv_result
Gets address information about the network interfaces on the system.
val interface_addresses_exn : unit -> interface_address array
val load_avg : unit -> float * float * float
Gets the load average. Returns 0,0,0
on Windows
val ip4_addr : string -> int -> Uwt_base.sockaddr Uwt_base.uv_result
Convert a string containing an IPv4 addresses to a binary structure.
val ip4_addr_exn : string -> int -> Uwt_base.sockaddr
val ip4_name : Uwt_base.sockaddr -> string Uwt_base.uv_result
Convert a binary structure containing an IPv4 address to a string.
val ip4_name_exn : Uwt_base.sockaddr -> string
val ip6_addr : string -> int -> Uwt_base.sockaddr Uwt_base.uv_result
Convert a string containing an IPv6 addresses to a binary structure.
val ip6_addr_exn : string -> int -> Uwt_base.sockaddr
val ip6_name : Uwt_base.sockaddr -> string Uwt_base.uv_result
Convert a binary structure containing an IPv6 address to a string.
val ip6_name_exn : Uwt_base.sockaddr -> string
val get_total_memory : unit -> int64
Gets memory information (in bytes).
val hrtime : unit -> int64
Returns the current high-resolution real time. This is expressed in nanoseconds. It is relative to an arbitrary time in the past. It is not related to the time of day and therefore not subject to clock drift. The primary use is for measuring performance between intervals.
Note: Not every platform can support nanosecond resolution; however, this value will always be in nanoseconds.
type
version = {
|
major : |
|
minor : |
|
patch : |
val version : unit -> version
libuv version used
val version_raw : unit -> int
val version_string : unit -> string
Many of the functions below are not thread safe
and might block.
Functions like cwd
are useful nevertheless,
if you target windows. Unlike Sys.getcwd()
they
return UTF8-encoded names
val os_homedir : unit -> string Uwt_base.uv_result
Gets the current user's home directory. On Windows, homedir
first checks the USERPROFILE environment
variable using
GetEnvironmentVariableW()
. If USERPROFILE
is not set,
GetUserProfileDirectoryW()
is called.
On all other operating systems, Uwt_base.Misc.os_homedir
first checks the
HOME
environment variable using getenv(3)
. If HOME
is not set,
getpwuid_r(3)
is called.
val os_tmpdir : unit -> string Uwt_base.uv_result
Gets the temp directory. On Windows, uv_os_tmpdir() uses GetTempPathW(). On all other operating systems, uv_os_tmpdir() uses the first environment variable found in the ordered list TMPDIR, TMP, TEMP, and TEMPDIR. If none of these are found, the path "/tmp" is used, or, on Android, "/data/local/tmp" is used.
val get_passwd : unit -> Unix.passwd_entry Uwt_base.uv_result
pw_passwd
and pw_gecos
will currently
always contain an empty string.
This function does work on Windows (unlike Unix.getpwnam
or Unix.getwuid
)
val exepath : unit -> string Uwt_base.uv_result
like Sys.executable_name , but utf-8 encoded under windows and perhaps more reliable under niche operating systems
val cwd : unit -> string Uwt_base.uv_result
Gets the current working directory
val chdir : string -> Uwt_base.Int_result.unit
Changes the current working directory.
val getenv : string -> string Uwt_base.uv_result
Return the value associated to a variable in the process environment. ENOENT is returned, if the variable is unbound.
val putenv : key:string -> data:string -> Uwt_base.Int_result.unit
putenv ~key ~data
sets the value associated to a variable in
the process environment. key
is the name of the environment
variable, and data
its new associated value.
val unsetenv : string -> Uwt_base.Int_result.unit
Deletes the environment variable specified by name. If no such environment variable exists, this function returns successfully.
val getppid : unit -> Uwt_base.Int_result.int
Returns the parent process ID. Similar to Unix.getppid
, but also works
under Windows
The following two functions don't work reliable, especially with byte code.
val set_process_title : string -> Uwt_base.Int_result.unit
Sets the process title. It won't necessary report an error, if it fails
val get_process_title : unit -> string Uwt_base.uv_result