Evm_node_lib_dev.Process_manager
Alternative implementation of Lwt_process
API which does not rely on Unix.fork
.
This module provides functions for creating and managing external processes. It uses Lwt_domain
to spawn processes, making it a safer alternative to Lwt_process
in multi-threaded applications that use system threads.
The API mirrors Lwt_process
, providing functions to open processes with different I/O configurations (open_process_in
, open_process_out
, etc.) and corresponding "with" functions (with_process_in
, etc.) that handle resource cleanup automatically.
Note: This module does not support the Windows platform.
open_process_in (command, args)
starts the given command. The standard output of the process is connected to a pipe, which can be read via the stdout
method of the returned object.
open_process_out (command, args)
starts the given command. The standard input of the process is connected to a pipe, which can be written to via the stdin
method of the returned object.
open_process (command, args)
starts the given command. The standard input and standard output of the process are connected to pipes, which can be accessed via the stdin
and stdout
methods of the returned object.
open_process_full (command, args)
starts the given command. The standard input, standard output, and standard error of the process are connected to pipes, accessible via the stdin
, stdout
, and stderr
methods of the returned object.
These are helper functions that manage the lifecycle of a process. They start a process, apply a given function, and ensure the process is properly closed afterward, even if the function raises an exception. This is the recommended way to interact with processes.
with_process_in cmd f
is a safe wrapper for open_process_in
. It starts a process, applies f
to the process object, and guarantees cleanup.
with_process_out cmd f
is a safe wrapper for open_process_out
. It starts a process, applies f
to the process object, and guarantees cleanup.
with_process cmd f
is a safe wrapper for open_process
. It starts a process, applies f
to the process object, and guarantees cleanup.