mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 08:56:40 +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
|
@ -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