(exit_code: i32, group_exit: bool)
| 153 | } |
| 154 | |
| 155 | pub 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. |
| 204 | pub fn raise_signal_fatal(sig: SignalInfo) -> AxResult<()> { |
no test coverage detected