package soteria

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Soteria_std.Subprocess

Tracked OS subprocesses.

A subprocess opened with open_ is recorded in an internal registry and force-killed when the host process exits -- normally or on an uncaught exception, via at_exit -- or is interrupted by SIGINT/SIGTERM, via a signal handler this module installs. This keeps a child that is busy and not reading its stdin (e.g. an SMT solver mid-check) from being orphaned: such a child does not notice its stdin pipe closing, so closing our end is not enough.

stop_process and force_stop_process are idempotent and unregister the subprocess, so one stopped explicitly is not touched again at exit.

type t

A subprocess and the channels connected to its standard streams.

val open_ : string -> string array -> t

open_ prog args spawns prog with argument vector args (as for Unix.open_process_args_full, so args.(0) is conventionally prog) and registers it for cleanup.

val stdin : t -> out_channel

The channel writing to the subprocess's standard input.

val stdout : t -> in_channel

The channel reading the subprocess's standard output.

val stderr : t -> in_channel

The channel reading the subprocess's standard error.

val stop_process : t -> unit

Close the subprocess with Unix.close_process_full and unregister it. Idempotent.

val force_stop_process : t -> unit

Kill the subprocess (SIGKILL), then close and unregister it as stop_process does. Idempotent.