Eio.Stdenv
The standard environment of a process.
All access to the outside world comes from running the event loop, which provides an environment (e.g. an Eio_unix.Stdenv.base
).
Example:
let () =
Eio_main.run @@ fun env ->
Eio.Path.with_open_dir env#fs "/srv/www" @@ fun www ->
serve_files www
~net:env#net
To use these, see Flow
.
val stdin : < stdin : _ Flow.source as 'a.. > -> 'a
val stdout : < stdout : _ Flow.sink as 'a.. > -> 'a
val stderr : < stderr : _ Flow.sink as 'a.. > -> 'a
To use these, see Path
.
val cwd : < cwd : _ Path.t as 'a.. > -> 'a
cwd t
is the current working directory of the process (this may change over time if the process does a "chdir" operation, which is not recommended).
val fs : < fs : _ Path.t as 'a.. > -> 'a
fs t
is the process's full access to the filesystem.
Paths can be absolute or relative (to the current working directory). Using relative paths with this is similar to using them with cwd
, except that this will follow ".." and symlinks to other parts of the filesystem.
fs
is useful for handling paths passed in by the user.
To use this, see Net
.
val net : < net : _ Net.t as 'a.. > -> 'a
net t
gives access to the process's network namespace.
To use this, see Process
.
val process_mgr : < process_mgr : _ Process.mgr as 'a.. > -> 'a
process_mgr t
allows you to manage child processes.
To use this, see Domain_manager
.
val domain_mgr : < domain_mgr : _ Domain_manager.t as 'a.. > -> 'a
domain_mgr t
allows running code on other cores.
To use this, see Time
.
val clock : < clock : _ Time.clock as 'a.. > -> 'a
clock t
is the system clock (used to get the current time and date).
val mono_clock : < mono_clock : _ Time.Mono.t as 'a.. > -> 'a
mono_clock t
is a monotonic clock (used for measuring intervals).
val secure_random : < secure_random : _ Flow.source as 'a.. > -> 'a
secure_random t
is an infinite source of random bytes suitable for cryptographic purposes.
val debug : < debug : < Debug.t.. > as 'a.. > -> 'a
debug t
provides privileged controls for debugging.