⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

sys_exit

Function sys_exit 

Source
pub fn sys_exit(_code: i32) -> !
Expand description

Terminate the current process with the given exit code.

Immediately terminates the calling process. All resources held by the process are released in the following order:

  1. All open file descriptors are closed.
  2. All memory mappings are unmapped and physical frames freed.
  3. All capabilities not shared with other processes are revoked.
  4. The process is moved to the zombie state until the parent calls sys_wait to collect the exit code.
  5. If the process has children, they are re-parented to the init process (PID 1).
  6. A SIGCHLD-equivalent notification is sent to the parent process.

This function never returns. After the cleanup sequence completes, the scheduler selects the next runnable process.

§Arguments

  • code - Exit status code. By convention, 0 indicates success and non-zero values indicate an error. The low 8 bits are made available to the parent via sys_wait.

§Examples

use veridian_kernel::pkg::sdk::syscall_api::sys_exit;

// Exit successfully
sys_exit(0);

// Exit with error code (this line is unreachable)