Skip to main content

spawn_soma_binary

Function spawn_soma_binary 

Source
async fn spawn_soma_binary(
    log_dir: &Path,
    name: &str,
    bin: &str,
    args: &[String],
) -> Result<(Spawned, File)>
Expand description

Spawn soma with an inherited pipe on SOMA_STAGE_FD. The parent keeps the write end and later writes stage2\n to it (see write_stage2_trigger below). Layered on spawn_system_binary’s stdio+scribe pattern but adds:

  • pipe() to create the trigger channel
  • pre_exec dup2 to move the child’s end onto SOMA_STAGE_FD (the natural fd from pipe() is unpredictable — some later lib open() call could grab it — so we pin it to a known number)
  • ROBONIX_SOMA_STAGE_FD env so soma finds it
  • close-on-exec cleared on the child fd (dup2 clears it by default, which is what we want)

Returns the Spawned handle and the parent’s write-end File. Drop the File to close the pipe (soma sees EOF and continues without stage 2 — matches the no fd env-absent path).