2020-07-31 00:38:15 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-07-31 00:38:15 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <Kernel/KSyms.h>
|
2021-05-07 08:29:19 +03:00
|
|
|
#include <Kernel/PerformanceManager.h>
|
2020-07-31 00:38:15 +03:00
|
|
|
#include <Kernel/Process.h>
|
2021-07-18 21:20:12 +03:00
|
|
|
#include <Kernel/Thread.h>
|
2020-07-31 00:38:15 +03:00
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
void Process::sys$exit(int status)
|
|
|
|
{
|
2021-10-01 02:48:31 +03:00
|
|
|
// FIXME: We have callers from kernel which don't acquire the big process lock.
|
2021-07-18 21:20:12 +03:00
|
|
|
if (Thread::current()->previous_mode() == Thread::PreviousMode::UserMode) {
|
|
|
|
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this);
|
|
|
|
}
|
|
|
|
|
2021-03-11 16:24:08 +03:00
|
|
|
{
|
|
|
|
ProtectedDataMutationScope scope { *this };
|
2021-08-07 22:30:06 +03:00
|
|
|
m_protected_values.termination_status = status;
|
|
|
|
m_protected_values.termination_signal = 0;
|
2021-03-11 16:24:08 +03:00
|
|
|
}
|
2021-04-26 00:42:36 +03:00
|
|
|
|
2021-05-07 08:29:19 +03:00
|
|
|
auto* current_thread = Thread::current();
|
2021-05-30 17:24:53 +03:00
|
|
|
current_thread->set_profiling_suppressed();
|
2021-05-07 08:29:19 +03:00
|
|
|
PerformanceManager::add_thread_exit_event(*current_thread);
|
2021-04-26 00:42:36 +03:00
|
|
|
|
2020-07-31 00:38:15 +03:00
|
|
|
die();
|
2021-05-07 08:29:19 +03:00
|
|
|
current_thread->die_if_needed();
|
2021-02-23 22:42:32 +03:00
|
|
|
VERIFY_NOT_REACHED();
|
2020-07-31 00:38:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|