[kernel] Clean up process::exit
Make process::exit slightly more resilient to being called again.
This commit is contained in:
@@ -52,16 +52,13 @@ void
|
|||||||
process::exit(unsigned code)
|
process::exit(unsigned code)
|
||||||
{
|
{
|
||||||
// TODO: make this thread-safe
|
// TODO: make this thread-safe
|
||||||
if (m_state != state::running)
|
|
||||||
return;
|
|
||||||
else
|
|
||||||
m_state = state::exited;
|
m_state = state::exited;
|
||||||
|
m_return_code = code;
|
||||||
|
close();
|
||||||
|
|
||||||
for (auto *thread : m_threads) {
|
for (auto *thread : m_threads) {
|
||||||
thread->exit(code);
|
thread->exit(code);
|
||||||
}
|
}
|
||||||
m_return_code = code;
|
|
||||||
close();
|
|
||||||
|
|
||||||
if (this == bsp_cpu_data.p)
|
if (this == bsp_cpu_data.p)
|
||||||
scheduler::get().schedule();
|
scheduler::get().schedule();
|
||||||
|
|||||||
Reference in New Issue
Block a user