pspawn

Number0x06
Signature(args*) -> {handle, pid} or -err
Grouptask
Since1.0

Create a frozen child process. First step of the three-step spawn sequence:

  1. pspawn creates a new FROZEN process and returns its handle and PID.
  2. asinject fills the new process’s address space with parsed ELF data.
  3. kickstart marks the process schedulable.

The child inherits the caller’s first four handle slots (0–3), so it starts with the name-server endpoint in slot 0 and can reach the system without further setup.

Pitfalls

The returned process is FROZEN and will not run until kickstart. Because asinject is init-only, ordinary processes spawn children by messaging init rather than driving the sequence themselves.

The task handle is retained after kickstart: hold it to pkill or wait the child; it is your only reference to it.

Arguments

RegisterNameDescription
r0argsPointer to a `spawn_args_t`; carries the process name and its length

Returns

r0 = task handle slot in the caller's table; r1 = the new child's PID.

Errors

CodeCondition
ERR_BADPTRArgs pointer invalid, or the name could not be copied
ERR_BADARG`size` is smaller than `sizeof(spawn_args_t)`
ERR_NOMEMCould not create the process, or the caller's handle table is full

See also