diff options
author | Ben Wiederhake <BenWiederhake.GitHub@gmx.de> | 2020-08-08 17:32:34 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-10 11:51:45 +0200 |
commit | f5744a6f2f63ba9f881132227514b9b3f9496b63 (patch) | |
tree | 0d8eb80d2df75f42ec76c3a8cad17d4aeaccea68 /Kernel/Syscalls/waitid.cpp | |
parent | f22532118411c675e5bd1d2487331e27a872a981 (diff) | |
download | serenity-f5744a6f2f63ba9f881132227514b9b3f9496b63.zip |
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
Diffstat (limited to 'Kernel/Syscalls/waitid.cpp')
-rw-r--r-- | Kernel/Syscalls/waitid.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Kernel/Syscalls/waitid.cpp b/Kernel/Syscalls/waitid.cpp index 2650680b5f..1d4c69ca48 100644 --- a/Kernel/Syscalls/waitid.cpp +++ b/Kernel/Syscalls/waitid.cpp @@ -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()) { |