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:
- All open file descriptors are closed.
- All memory mappings are unmapped and physical frames freed.
- All capabilities not shared with other processes are revoked.
- The process is moved to the zombie state until the parent calls
sys_waitto collect the exit code. - If the process has children, they are re-parented to the init process (PID 1).
- 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,0indicates success and non-zero values indicate an error. The low 8 bits are made available to the parent viasys_wait.
§Examples
use veridian_kernel::pkg::sdk::syscall_api::sys_exit;
// Exit successfully
sys_exit(0);
// Exit with error code (this line is unreachable)