mirror of
https://git.citron-emu.org/Citron/Citron.git
synced 2025-02-07 08:46:25 +01:00
kernel/svc: Implement InitialProcessIdRange and improve process exit handling
- Replace stubbed InitialProcessIdRange implementation with proper bounds (1-0x50) - Add handle and info_sub_id validation for InitialProcessIdRange - Replace process exit ASSERT with graceful error handling and logging - Add try-catch block around system.Exit() for safer shutdown - Add atomic header inclusion for binder.h This improves system call reliability by properly implementing process ID range checks and adding safer process exit handling with proper error logging.
This commit is contained in:
parent
9a3d4f0489
commit
613099703a
4 changed files with 24 additions and 7 deletions
|
@ -174,9 +174,15 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
|
|
||||||
case InfoType::InitialProcessIdRange:
|
case InfoType::InitialProcessIdRange:
|
||||||
LOG_WARNING(Kernel_SVC,
|
R_UNLESS(handle == 0, ResultInvalidHandle);
|
||||||
"(STUBBED) Attempted to query privileged process id bounds, returned 0");
|
R_UNLESS(info_sub_id <= 1, ResultInvalidCombination);
|
||||||
*result = 0;
|
|
||||||
|
// Return the valid range for initial process IDs
|
||||||
|
if (info_sub_id == 0) {
|
||||||
|
*result = 1; // Minimum initial process ID
|
||||||
|
} else {
|
||||||
|
*result = 0x50; // Maximum initial process ID
|
||||||
|
}
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
|
|
||||||
case InfoType::ThreadTickCount: {
|
case InfoType::ThreadTickCount: {
|
||||||
|
|
|
@ -12,10 +12,19 @@ void ExitProcess(Core::System& system) {
|
||||||
auto* current_process = GetCurrentProcessPointer(system.Kernel());
|
auto* current_process = GetCurrentProcessPointer(system.Kernel());
|
||||||
|
|
||||||
LOG_INFO(Kernel_SVC, "Process {} exiting", current_process->GetProcessId());
|
LOG_INFO(Kernel_SVC, "Process {} exiting", current_process->GetProcessId());
|
||||||
ASSERT_MSG(current_process->GetState() == KProcess::State::Running,
|
|
||||||
"Process has already exited");
|
|
||||||
|
|
||||||
|
// Check if process is in a valid state for exit
|
||||||
|
if (current_process->GetState() != KProcess::State::Running) {
|
||||||
|
LOG_WARNING(Kernel_SVC, "Process {} already exiting or in invalid state", current_process->GetProcessId());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure clean shutdown
|
||||||
|
try {
|
||||||
system.Exit();
|
system.Exit();
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
LOG_ERROR(Kernel_SVC, "Error during process exit: {}", e.what());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the ID of the specified process or a specified thread's owning process.
|
/// Gets the ID of the specified process or a specified thread's owning process.
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||||
// SPDX-FileCopyrightText: Copyright 2014 The Android Open Source Project
|
// SPDX-FileCopyrightText: Copyright 2014 The Android Open Source Project
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
// Parts of this implementation were based on:
|
// Parts of this implementation were based on:
|
||||||
// https://cs.android.com/android/platform/superproject/+/android-5.1.1_r38:frameworks/native/include/binder/IBinder.h
|
// https://cs.android.com/android/platform/superproject/+/android-5.1.1_r38:frameworks/native/include/binder/IBinder.h
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
#include <span>
|
#include <span>
|
||||||
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
|
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
|
||||||
"name": "citron",
|
"name": "citron",
|
||||||
"builtin-baseline": "c82f74667287d3dc386bce81e44964370c91a289",
|
"builtin-baseline": "7adc2e4d49e8d0efc07a369079faa6bc3dbb90f3",
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"boost-algorithm",
|
"boost-algorithm",
|
||||||
|
|
Loading…
Reference in a new issue