kernel/syscall/syscalls/exit.rs
1// SPDX-License-Identifier: GPL-3.0-only
2//! Exit Syscall Handler
3//!
4//! Authors: MarioS271
5
6use crate::lib::panic::kernel_panic;
7use crate::lib::panic_codes::PanicCode;
8use crate::state::kstate::KSTATE;
9
10/// Exit Syscall Handler
11pub fn handler(exit_code: u32) -> ! {
12 let pid = KSTATE.sched.active_pid();
13 // Safety: syscalls get inited in stage 2, this only needs stage 0
14 unsafe { KSTATE.sched.remove_process(pid) };
15
16 crate::kdebug!("Process {} exited with code {}", pid, exit_code);
17
18 // TODO: properly exit
19 kernel_panic(
20 PanicCode::InitProcessDied,
21 "Process exited"
22 );
23}