1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 22:48:11 +00:00

Kernel: Ignore subsequent calls to Process::die

It's possible that another thread might try to exit the process just
about the same time another thread does the same, or a crash happens.
Also, we may not be able to kill all other threads instantly as they
may be blocked in the kernel (though in this case they would get killed
before ever returning back to user mode. So keep track of whether
Process::die was already called and ignore it on subsequent calls.

Fixes #8485
This commit is contained in:
Tom 2021-07-13 17:15:24 -06:00 committed by Andreas Kling
parent 3cc0283eac
commit d7e5521a04
3 changed files with 25 additions and 3 deletions

View file

@ -148,6 +148,12 @@ class Process
Process& m_process;
};
enum class State : u8 {
Running = 0,
Dying,
Dead
};
public:
inline static Process* current()
{
@ -201,7 +207,8 @@ public:
bool should_core_dump() const { return m_should_dump_core; }
void set_dump_core(bool dump_core) { m_should_dump_core = dump_core; }
bool is_dead() const { return m_dead; }
bool is_dying() const { return m_state.load(AK::MemoryOrder::memory_order_acquire) != State::Running; }
bool is_dead() const { return m_state.load(AK::MemoryOrder::memory_order_acquire) == State::Dead; }
bool is_stopped() const { return m_is_stopped; }
bool set_stopped(bool stopped) { return m_is_stopped.exchange(stopped); }
@ -670,7 +677,7 @@ private:
mutable RecursiveSpinLock m_thread_list_lock;
const bool m_is_kernel_process;
bool m_dead { false };
Atomic<State> m_state { State::Running };
bool m_profiling { false };
Atomic<bool, AK::MemoryOrder::memory_order_relaxed> m_is_stopped { false };
bool m_should_dump_core { false };