Kernel: Remove waitpid() debug messages and add more checks

This commit is contained in:
apio 2022-10-30 19:24:56 +01:00
parent e244c150c2
commit 9c3792718c

View File

@ -510,10 +510,16 @@ void sys_waitpid(Context* context, long pid, int* wstatus,
child = Scheduler::find_by_pid(pid);
if (!child)
{
context->rax = -ESRCH;
context->rax = -ECHILD;
return;
}
}
if (child->ppid != sched_current_task->id)
{
// We are trying to call waitpid() on a task that isn't a child of ours. This is not allowed.
context->rax = -ECHILD;
return;
}
if (child->state != child->Dying)
{
if (options & WNOHANG)
@ -531,7 +537,6 @@ void sys_waitpid(Context* context, long pid, int* wstatus,
return;
}
}
kdbgln("blocking wait on pid %ld", pid);
sched_current_task->state = sched_current_task->Blocking;
sched_current_task->block_reason = BlockReason::Waiting;
sched_current_task->blocking_wait_info.wait_pid = pid;
@ -583,6 +588,8 @@ bool Task::is_wait_still_blocking()
else
{
child = Scheduler::find_by_pid(blocking_wait_info.wait_pid);
ASSERT(child); // since sys_waitpid should have validated this child, and the only way for it to disappear from
// the process list is for someone to wait for it, this should be pretty safe.
if (child->state != child->Dying) return true;
else
return false;
@ -596,8 +603,6 @@ void Task::resume_wait()
Task* child = Scheduler::find_by_pid(blocking_wait_info.wait_pid);
ASSERT(child); // This should also already have been validated.
kdbgln("resuming wait on child %ld", child->id);
if (blocking_wait_info.wstatus)
{
*blocking_wait_info.wstatus = (int)(child->exit_status & 0xff);