Skip to main content

fallow_process/
lib.rs

1//! Shared subprocess lifecycle management for Fallow.
2//!
3//! Protocol adapters and analysis facades use the same registered child
4//! handles and operating-system process-tree primitives. This keeps timeout
5//! cleanup and signal cleanup identical without introducing dependencies on
6//! the CLI crate.
7//!
8//! The optional `tokio` feature adds async command setup and bounded cleanup
9//! while preserving the same operating-system tree owner.
10
11#[cfg(target_os = "linux")]
12mod proc_state;
13mod process_tree;
14mod registry;
15mod scoped_child;
16mod spawn_retry;
17
18pub use process_tree::{ChildCleanup, ProcessTree, cleanup_std_child, configure_std_command};
19#[cfg(feature = "tokio")]
20pub use process_tree::{cleanup_tokio_child, configure_tokio_command};
21pub use scoped_child::{ProcessTreeTerminator, ScopedChild, output, status};
22pub use spawn_retry::spawn_retrying_busy_executable;
23#[cfg(feature = "tokio")]
24pub use spawn_retry::spawn_tokio_retrying_busy_executable;
25
26/// Terminate every registered child or process tree and wait for bounded
27/// cleanup.
28pub fn drain_and_kill() {
29    registry::drain_and_kill();
30}
31
32/// Like [`drain_and_kill`], but skip the cleanup when another thread holds
33/// the registry lock. Use it from a panic hook, where a blocking lock can
34/// deadlock.
35pub fn try_drain_and_kill() {
36    registry::try_drain_and_kill();
37}