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