ladybird/Kernel/Syscalls/exit.cpp
Brian Gianforcaro 9201a06027 Kernel: Annotate all syscalls with VERIFY_PROCESS_BIG_LOCK_ACQUIRED
Before we start disabling acquisition of the big process lock for
specific syscalls, make sure to document and assert that all the
lock is held during all syscalls.
2021-07-20 03:21:14 +02:00

37 lines
889 B
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/KSyms.h>
#include <Kernel/PerformanceManager.h>
#include <Kernel/Process.h>
#include <Kernel/Thread.h>
namespace Kernel {
void Process::sys$exit(int status)
{
// FIXME: We have callers from kernel which don't aquire the big process lock.
if (Thread::current()->previous_mode() == Thread::PreviousMode::UserMode) {
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this);
}
{
ProtectedDataMutationScope scope { *this };
m_termination_status = status;
m_termination_signal = 0;
}
auto* current_thread = Thread::current();
current_thread->set_profiling_suppressed();
PerformanceManager::add_thread_exit_event(*current_thread);
die();
current_thread->die_if_needed();
VERIFY_NOT_REACHED();
}
}