MCPcopy Create free account
hub / github.com/Starry-OS/StarryOS / do_exit

Function do_exit

api/src/task.rs:155–201  ·  view source on GitHub ↗
(exit_code: i32, group_exit: bool)

Source from the content-addressed store, hash-verified

153}
154
155pub fn do_exit(exit_code: i32, group_exit: bool) {
156 let curr = current();
157 let thr = curr.as_thread();
158
159 info!("{} exit with code: {}", curr.id_name(), exit_code);
160
161 let clear_child_tid = thr.clear_child_tid() as *mut u32;
162 if clear_child_tid.vm_write(0).is_ok() {
163 let key = FutexKey::new_current(clear_child_tid as usize);
164 let table = thr.proc_data.futex_table_for(&key);
165 let guard = table.get(&key);
166 if let Some(futex) = guard {
167 futex.wq.wake(1, u32::MAX);
168 }
169 axtask::yield_now();
170 }
171 let head = thr.robust_list_head() as *const RobustListHead;
172 if !head.is_null()
173 && let Err(err) = exit_robust_list(head)
174 {
175 warn!("exit robust list failed: {err:?}");
176 }
177
178 let process = &thr.proc_data.proc;
179 if process.exit_thread(curr.id().as_u64() as Pid, exit_code) {
180 process.exit();
181 if let Some(parent) = process.parent() {
182 if let Some(signo) = thr.proc_data.exit_signal {
183 let _ = send_signal_to_process(parent.pid(), Some(SignalInfo::new_kernel(signo)));
184 }
185 if let Ok(data) = get_process_data(parent.pid()) {
186 data.child_exit_event.wake();
187 }
188 }
189 thr.proc_data.exit_event.wake();
190
191 SHM_MANAGER.lock().clear_proc_shm(process.pid());
192 }
193 if group_exit && !process.is_group_exited() {
194 process.group_exit();
195 let sig = SignalInfo::new_kernel(Signo::SIGKILL);
196 for tid in process.threads() {
197 let _ = send_signal_to_thread(None, tid, Some(sig.clone()));
198 }
199 }
200 thr.set_exit();
201}
202
203/// Sends a fatal signal to the current process.
204pub fn raise_signal_fatal(sig: SignalInfo) -> AxResult<()> {

Callers 4

check_signalsFunction · 0.85
raise_signal_fatalFunction · 0.85
sys_exitFunction · 0.85
sys_exit_groupFunction · 0.85

Calls 13

exit_robust_listFunction · 0.85
send_signal_to_processFunction · 0.85
get_process_dataFunction · 0.85
send_signal_to_threadFunction · 0.85
as_threadMethod · 0.80
clear_child_tidMethod · 0.80
futex_table_forMethod · 0.80
robust_list_headMethod · 0.80
is_nullMethod · 0.80
clear_proc_shmMethod · 0.80
set_exitMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected