mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
Kernel: Allow dead threads to be joined
Joining dead threads is allowed for two main reasons: - Thread join behavior should not be racy when a thread is joined and exiting at roughly the same time. This is common behavior when threads are given a signal to end (meaning they are going to exit ASAP) and then joined. - POSIX requires that exited threads are joinable (at least, there is no language in the specification forbidding it). The behavior is still well-defined; e.g. it doesn't allow a dead detached thread to be joined or a thread to be joined more than once.
This commit is contained in:
parent
8997d825d5
commit
bfb3fc58dd
Notes:
sideshowbarker
2024-07-17 03:24:40 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/bfb3fc58dd Pull-request: https://github.com/SerenityOS/serenity/pull/16011 Reviewed-by: https://github.com/ADKaster ✅
1 changed files with 6 additions and 1 deletions
|
@ -824,7 +824,12 @@ public:
|
|||
return EDEADLK;
|
||||
|
||||
SpinlockLocker lock(m_lock);
|
||||
if (!m_is_joinable || state() == Thread::State::Dead)
|
||||
|
||||
// Joining dead threads is allowed for two main reasons:
|
||||
// - Thread join behavior should not be racy when a thread is joined and exiting at roughly the same time.
|
||||
// This is common behavior when threads are given a signal to end (meaning they are going to exit ASAP) and then joined.
|
||||
// - POSIX requires that exited threads are joinable (at least, there is no language in the specification forbidding it).
|
||||
if (!m_is_joinable || state() == Thread::State::Invalid)
|
||||
return EINVAL;
|
||||
|
||||
add_blocker();
|
||||
|
|
Loading…
Reference in a new issue