1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 03:17:34 +00:00

Kernel: PID/TID typing

This compiles, and contains exactly the same bugs as before.
The regex 'FIXME: PID/' should reveal all markers that I left behind, including:
- Incomplete conversion
- Issues or things that look fishy
- Actual bugs that will go wrong during runtime
This commit is contained in:
Ben Wiederhake 2020-08-08 17:32:34 +02:00 committed by Andreas Kling
parent f225321184
commit f5744a6f2f
26 changed files with 136 additions and 111 deletions

View file

@ -34,9 +34,12 @@ KResultOr<siginfo_t> Process::do_waitid(idtype_t idtype, int id, int options)
ScopedSpinLock lock(g_processes_lock);
if (idtype == P_PID && !Process::from_pid(id))
return KResult(-ECHILD);
// FIXME: Race: After 'lock' releases, the 'id' process might vanish.
// If that is not a problem, why check for it?
// If it is a problem, let's fix it! (Eventually.)
}
pid_t waitee_pid;
ProcessID waitee_pid { 0 };
// FIXME: WaitBlocker should support idtype/id specs directly.
if (idtype == P_ALL) {
@ -62,14 +65,15 @@ KResultOr<siginfo_t> Process::do_waitid(idtype_t idtype, int id, int options)
if (waitee_process->is_dead()) {
return reap(*waitee_process);
} else {
auto* waitee_thread = Thread::from_tid(waitee_pid);
// FIXME: PID/TID BUG
auto* waitee_thread = Thread::from_tid(waitee_pid.value());
if (!waitee_thread)
return KResult(-ECHILD);
ASSERT((options & WNOHANG) || waitee_thread->state() == Thread::State::Stopped);
siginfo_t siginfo;
memset(&siginfo, 0, sizeof(siginfo));
siginfo.si_signo = SIGCHLD;
siginfo.si_pid = waitee_process->pid();
siginfo.si_pid = waitee_process->pid().value();
siginfo.si_uid = waitee_process->uid();
switch (waitee_thread->state()) {