//! Process control. use crate::sys; unsafe extern "C" { // libc exit(): runs atexit handlers (and .fini_array), then SYS_EXIT. #[link_name = "exit"] fn libc_exit(code: i32) -> !; } /// Exit the process. From a sibling thread this ends only that thread /// (kernel semantics); use [`abort`] to take the whole process down. pub fn exit(code: i32) -> ! { unsafe { libc_exit(code) } } pub fn id() -> u32 { unsafe { sys::syscall0(sys::SYS_GETPID) as u32 } } /// Terminate the whole process from any thread. Waiters see exit code /// TerminatedAborted (256 + SIGABRT). pub fn abort() -> ! { unsafe { sys::syscall0(sys::SYS_ABORT); // Not reached. No panic here: the panic handler calls abort(). loop { sys::syscall0(sys::SYS_YIELD); } } }