summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls/exit.cpp
blob: fa2faf357ba93376d7120eeebe54d5e7ef18ad84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
 * 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>

namespace Kernel {

void Process::sys$exit(int status)
{
    {
        ProtectedDataMutationScope scope { *this };
        m_termination_status = status;
        m_termination_signal = 0;
    }

    auto* current_thread = Thread::current();
    PerformanceManager::add_thread_exit_event(*current_thread);

    die();
    current_thread->die_if_needed();
    VERIFY_NOT_REACHED();
}

}