mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 17:52:26 -05:00
01b79910b3
The compiler can re-order the structure (class) members if that's necessary, so if we make Process to inherit from ProcFSExposedComponent, even if the declaration is to inherit first from ProcessBase, then from ProcFSExposedComponent and last from Weakable<Process>, the members of class ProcFSExposedComponent (including the Ref-counted parts) are the first members of the Process class. This problem made it impossible to safely use the current toggling method with the write-protection bit on the ProcessBase members, so instead of inheriting from it, we make its members the last ones in the Process class so we can safely locate and modify the corresponding page write protection bit of these values. We make sure that the Process class doesn't expand beyond 8192 bytes and the protected values are always aligned on a page boundary.
36 lines
923 B
C++
36 lines
923 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_protected_values.termination_status = status;
|
|
m_protected_values.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();
|
|
}
|
|
|
|
}
|