Kernel: Remove waitpid() debug messages and add more checks
This commit is contained in:
parent
e244c150c2
commit
9c3792718c
@ -510,10 +510,16 @@ void sys_waitpid(Context* context, long pid, int* wstatus,
|
|||||||
child = Scheduler::find_by_pid(pid);
|
child = Scheduler::find_by_pid(pid);
|
||||||
if (!child)
|
if (!child)
|
||||||
{
|
{
|
||||||
context->rax = -ESRCH;
|
context->rax = -ECHILD;
|
||||||
return;
|
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 (child->state != child->Dying)
|
||||||
{
|
{
|
||||||
if (options & WNOHANG)
|
if (options & WNOHANG)
|
||||||
@ -531,7 +537,6 @@ void sys_waitpid(Context* context, long pid, int* wstatus,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
kdbgln("blocking wait on pid %ld", pid);
|
|
||||||
sched_current_task->state = sched_current_task->Blocking;
|
sched_current_task->state = sched_current_task->Blocking;
|
||||||
sched_current_task->block_reason = BlockReason::Waiting;
|
sched_current_task->block_reason = BlockReason::Waiting;
|
||||||
sched_current_task->blocking_wait_info.wait_pid = pid;
|
sched_current_task->blocking_wait_info.wait_pid = pid;
|
||||||
@ -583,6 +588,8 @@ bool Task::is_wait_still_blocking()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
child = Scheduler::find_by_pid(blocking_wait_info.wait_pid);
|
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;
|
if (child->state != child->Dying) return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
@ -596,8 +603,6 @@ void Task::resume_wait()
|
|||||||
Task* child = Scheduler::find_by_pid(blocking_wait_info.wait_pid);
|
Task* child = Scheduler::find_by_pid(blocking_wait_info.wait_pid);
|
||||||
ASSERT(child); // This should also already have been validated.
|
ASSERT(child); // This should also already have been validated.
|
||||||
|
|
||||||
kdbgln("resuming wait on child %ld", child->id);
|
|
||||||
|
|
||||||
if (blocking_wait_info.wstatus)
|
if (blocking_wait_info.wstatus)
|
||||||
{
|
{
|
||||||
*blocking_wait_info.wstatus = (int)(child->exit_status & 0xff);
|
*blocking_wait_info.wstatus = (int)(child->exit_status & 0xff);
|
||||||
|
Loading…
Reference in New Issue
Block a user