scoped_task

Function spawn_etc

Source
pub fn spawn_etc<'a>(
    job: impl Borrow<&'a Scoped<Job>>,
    options: SpawnOptions,
    path: &CStr,
    argv: &[&CStr],
    environ: Option<&[&CStr]>,
    actions: &mut [SpawnAction<'_>],
) -> Result<Scoped<Process>, (Status, String)>
Expand description

A convenience wrapper around fdio::spawn_etc that returns a Scoped.

Note that you must assign the return value to a local. You can use a leading underscore in the name to avoid the unused variable lint, but don’t use just _ or the process will be killed immediately. For example,

let _process = scoped_task::spawn_etc(
    &scoped_task::job_default(),
    SpawnOptions::CLONE_ALL,
    c"/pkg/bin/echo",
    &[c"hello world"],
    None,
    &mut [],
).expect("could not spawn process");