Fix ptrace returning ENODEV when process exists

This commit is contained in:
jD91mZM2
2020-06-16 13:42:04 +02:00
parent cbb17327aa
commit 9c891384ea
3 changed files with 23 additions and 11 deletions
+3 -3
View File
@@ -1065,6 +1065,8 @@ pub fn fexec(fd: FileHandle, arg_ptrs: &[[usize; 2]], var_ptrs: &[[usize; 2]]) -
}
pub fn exit(status: usize) -> ! {
ptrace::breakpoint_callback(PTRACE_STOP_EXIT, Some(ptrace_event!(PTRACE_STOP_EXIT, status)));
{
let context_lock = {
let contexts = context::contexts();
@@ -1072,8 +1074,6 @@ pub fn exit(status: usize) -> ! {
Arc::clone(&context_lock)
};
ptrace::breakpoint_callback(PTRACE_STOP_EXIT, Some(ptrace_event!(PTRACE_STOP_EXIT, status)));
let mut close_files = Vec::new();
let pid = {
let mut context = context_lock.write();
@@ -1152,7 +1152,7 @@ pub fn exit(status: usize) -> ! {
}
// Alert any tracers waiting of this process
ptrace::close_session(pid);
ptrace::close_tracee(pid);
if pid == ContextId::from(1) {
println!("Main kernel thread exited with status {:X}", status);