mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-22 10:19:20 +00:00
Kernel: Use Process::get_thread_from_thread_list in Syscalls/thread.cpp
Some syscalls could be simplified by using the non-static method Process::get_thread_from_thread_list which should ensure that the specified tid is of a Thread in the same Process of the current Thread.
This commit is contained in:
parent
50429d3b22
commit
3a55a1b592
Notes:
sideshowbarker
2024-07-16 21:42:29 +09:00
Author: https://github.com/supercomputer7
Commit: 3a55a1b592
Pull-request: https://github.com/SerenityOS/serenity/pull/21001
Issue: https://github.com/SerenityOS/serenity/issues/20899
Reviewed-by: https://github.com/kleinesfilmroellchen ✅
1 changed files with 3 additions and 12 deletions
|
@ -125,10 +125,7 @@ ErrorOr<FlatPtr> Process::sys$detach_thread(pid_t tid)
|
|||
{
|
||||
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this);
|
||||
TRY(require_promise(Pledge::thread));
|
||||
auto thread = Thread::from_tid(tid);
|
||||
if (!thread || thread->pid() != pid())
|
||||
return ESRCH;
|
||||
|
||||
auto thread = TRY(get_thread_from_thread_list(tid));
|
||||
if (!thread->is_joinable())
|
||||
return EINVAL;
|
||||
|
||||
|
@ -141,10 +138,7 @@ ErrorOr<FlatPtr> Process::sys$join_thread(pid_t tid, Userspace<void**> exit_valu
|
|||
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this);
|
||||
TRY(require_promise(Pledge::thread));
|
||||
|
||||
auto thread = Thread::from_tid(tid);
|
||||
if (!thread || thread->pid() != pid())
|
||||
return ESRCH;
|
||||
|
||||
auto thread = TRY(get_thread_from_thread_list(tid));
|
||||
auto* current_thread = Thread::current();
|
||||
if (thread == current_thread)
|
||||
return EDEADLK;
|
||||
|
@ -179,10 +173,7 @@ ErrorOr<FlatPtr> Process::sys$kill_thread(pid_t tid, int signal)
|
|||
if (signal < 0 || signal >= NSIG)
|
||||
return EINVAL;
|
||||
|
||||
auto thread = Thread::from_tid(tid);
|
||||
if (!thread || thread->pid() != pid())
|
||||
return ESRCH;
|
||||
|
||||
auto thread = TRY(get_thread_from_thread_list(tid));
|
||||
if (signal != 0)
|
||||
thread->send_signal(signal, &Process::current());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue