wasmer_wasix/syscalls/wasix/
proc_exec2.rs

1use wasmer::FromToNativeWasmType;
2
3use super::*;
4use crate::{
5    os::task::{OwnedTaskStatus, TaskStatus},
6    syscalls::*,
7};
8
9/// Replaces the current process with a new process
10///
11/// ## Parameters
12///
13/// * `name` - Name of the process to be spawned
14/// * `args` - List of the arguments to pass the process
15///   (entries are separated by line feeds)
16/// * `envs` - List of the environment variables to pass process
17///
18/// ## Return
19///
20/// Returns a bus process id that can be used to invoke calls
21#[instrument(level = "trace", skip_all, fields(name = field::Empty, %args_len), ret)]
22pub fn proc_exec2<M: MemorySize>(
23    mut ctx: FunctionEnvMut<'_, WasiEnv>,
24    name: WasmPtr<u8, M>,
25    name_len: M::Offset,
26    args: WasmPtr<u8, M>,
27    args_len: M::Offset,
28    envs: WasmPtr<u8, M>,
29    envs_len: M::Offset,
30) -> Result<(), WasiError> {
31    match proc_exec3(
32        ctx,
33        name,
34        name_len,
35        args,
36        args_len,
37        envs,
38        envs_len,
39        Bool::False,
40        WasmPtr::null(),
41        0u32.into(),
42    ) {
43        Ok(e) => Err(WasiError::Exit(e.into())),
44        Err(e) => Err(e),
45    }
46}