Enforce causal child acquisition boundaries

This commit is contained in:
ms2k 2026-07-14 23:50:30 +09:00
commit 6f722ce079

View file

@ -1,10 +1,7 @@
use std::ffi::OsString;
use std::process::ExitCode;
use lazaret_linux::process::{
BarrierWait, arm_parent_death_and_recheck, exec_target, parse_wrapper_arguments,
};
use rustix::process::Signal;
use lazaret_linux::process::{dispatch_private_process_role, exec_target};
fn main() -> ExitCode {
match run() {
@ -18,6 +15,9 @@ fn main() -> ExitCode {
fn run() -> std::io::Result<()> {
let arguments = std::env::args_os().skip(1).collect::<Vec<OsString>>();
if let Some(result) = dispatch_private_process_role(&arguments) {
return result;
}
if arguments == [OsString::from("--trace-self-test")] {
let (release, wait) = lazaret_linux::process::launch_barrier()?;
release.release()?;
@ -26,9 +26,7 @@ fn run() -> std::io::Result<()> {
"/bin/true",
)));
}
let (expected_parent, target) = parse_wrapper_arguments(arguments)?;
BarrierWait::from_stdin()?.wait()?;
rustix::io::fcntl_setfd(std::io::stdin(), rustix::io::FdFlags::CLOEXEC)?;
arm_parent_death_and_recheck(Signal::KILL, expected_parent)?;
Err(exec_target(target))
Err(std::io::Error::other(
"no public wrapper command was requested",
))
}