Skip to main content

sys_waitpid

Function sys_waitpid 

Source
pub fn sys_waitpid(
    pid: i64,
    status_ptr: u64,
    options: u32,
) -> Result<u64, SyscallError>
Expand description

SYS_PROC_WAITPID (310): wait for a child process to exit.

Arguments:

  • pid : child task ID to wait for, or -1 (any child).
  • status_ptr : userspace *i32 to receive the encoded wait status (W_EXITCODE). Pass 0 to discard.
  • options : WNOHANG (1) — return immediately if no child ready.

Returns:

  • child task ID on success.
  • 0 if WNOHANG and no child has exited yet.

Errors:

  • -ECHILD (-10) — no matching children.
  • -EINTR (-4) — interrupted by a pending signal.
  • -EINVAL (-22) — unknown option bits.