loader: keep the output and log of a game LoadExec relaunches #1480

Manually merged
github merged 4 commits from gh-pr/1480/head into gh-pr/1480/base 2026-11-26 09:57:41 +00:00
Owner

@⁠Almo7aya on GitHub · 2026-10-13 16:51 UTC · original
Almo7aya:fix/loadexec-child-output → main · +77 −10 · 3 files · 4 commits · merged 2026-10-16 01:01 UTC

Game

Uncharted: Legacy of Thieves Collection (PPSA05389, 01.002.000) — The Lost Legacy.

Problem

When The Lost Legacy was the last game played, the collection's eboot.bin relaunches itself into
/app0/tllr-boot.bin through sceSystemServiceLoadExec. LoadExec starts a new emulator program
(a new process on Windows, exec on Linux), and the output around that switch was lost:

  • On Windows the new process was created with CREATE_NO_WINDOW and without the standard handles,
    so nothing it printed reached the console or the redirected stdout/stderr. Launched from the
    launcher, the console stopped at the relaunch; with output redirected to a file, the file ended there.
  • With --printf-direction File, the new program is given the same --printf-output-file and opened
    it anew, emptying it: the log kept only the second program, without anything the collection logged
    before the relaunch (its LoadExec: line included).
  • Output still buffered when LoadExec ran could appear after the new program's first lines (Windows)
    or be dropped (Linux, exec discards it).

Any error after the relaunch, fatal errors included, was invisible.

Changes

  1. loader: keep the output of a process LoadExec relaunches (Windows) — the new process gets the
    current standard input, output and error handles. Only those are inherited
    (PROC_THREAD_ATTRIBUTE_HANDLE_LIST), and it shares the console when there is one;
    CREATE_NO_WINDOW is only used when the current process has no console.
  2. loader: flush output before LoadExec starts the new program — the log and all C streams are
    flushed before the new program starts, on both platforms.
  3. loader: continue the log file across LoadExec — LoadExec sets KYTY_RELAUNCHED for the
    program it starts, which then appends to the printf output file instead of replacing it. A normal
    start still begins a new file.
  4. loader: show LoadExec switches on the console — the switch is written to the console as well as
    the log, with the new program's arguments, so it is clear where one program's output ends and the
    next one's begins:
    LoadExec: switching to /app0/tllr-boot.bin "" "boot-mode-tll".

Evidence

Collection eboot.bin, The Lost Legacy as the last game played.

Console (the launcher's cmd /K window) or stdout/stderr redirected to a file:

  • before: one startup block (the collection's), then nothing;
  • after: the switch, then the relaunched process's startup block and output, for example the error
    the relaunched process currently stops with on main:
Title ID: PPSA05389
Unresolved import stub called: DK+GoXCNT04[Http_v1][Http_v1.1][Func]
LoadExec: switching to /app0/tllr-boot.bin "" "boot-mode-tll"
Initialized: Config
...
Title ID: PPSA05389
Unresolved import stub called: LibwuIonIBw[VideoOutVrrStatus_v1][VideoOut_v1.1][Func]
--- Fatal Error ---
Error: condition (!Active()) is true in .../commandScheduler.cpp:325

(That error is a separate issue; starting tllr-boot.bin directly with --guest-exec shows the same
error. These changes only make it visible.)

--printf-direction File --printf-output-file log.txt (file pre-filled with an old line):

  • before: only the relaunched program's lines;
  • after: the old line is gone (a normal start still replaces the file), the collection's lines run up
    to LoadExec: switching to /app0/tllr-boot.bin "" "boot-mode-tll", and the relaunched program's
    lines follow it, through the error above.

Testing

  • Windows 11, RTX 4070, from the command line: console, redirected stdout/stderr and
    --printf-direction File, as above.

  • From the launcher: the relaunched program's output continues in the launcher's console, and
    _kyty.txt holds both programs' output.

    This needs to be tested on Linux and macOS

AI use

These changes were developed with an AI coding assistant

**@⁠Almo7aya** on GitHub · 2026-10-13 16:51 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1480) `Almo7aya:fix/loadexec-child-output` → `main` · +77 −10 · 3 files · 4 commits · merged 2026-10-16 01:01 UTC ## Game Uncharted: Legacy of Thieves Collection (PPSA05389, 01.002.000) — The Lost Legacy. ## Problem When The Lost Legacy was the last game played, the collection's `eboot.bin` relaunches itself into `/app0/tllr-boot.bin` through `sceSystemServiceLoadExec`. LoadExec starts a new emulator program (a new process on Windows, `exec` on Linux), and the output around that switch was lost: - On Windows the new process was created with `CREATE_NO_WINDOW` and without the standard handles, so nothing it printed reached the console or the redirected stdout/stderr. Launched from the launcher, the console stopped at the relaunch; with output redirected to a file, the file ended there. - With `--printf-direction File`, the new program is given the same `--printf-output-file` and opened it anew, emptying it: the log kept only the second program, without anything the collection logged before the relaunch (its `LoadExec:` line included). - Output still buffered when LoadExec ran could appear after the new program's first lines (Windows) or be dropped (Linux, `exec` discards it). Any error after the relaunch, fatal errors included, was invisible. ## Changes 1. **loader: keep the output of a process LoadExec relaunches** (Windows) — the new process gets the current standard input, output and error handles. Only those are inherited (`PROC_THREAD_ATTRIBUTE_HANDLE_LIST`), and it shares the console when there is one; `CREATE_NO_WINDOW` is only used when the current process has no console. 2. **loader: flush output before LoadExec starts the new program** — the log and all C streams are flushed before the new program starts, on both platforms. 3. **loader: continue the log file across LoadExec** — LoadExec sets `KYTY_RELAUNCHED` for the program it starts, which then appends to the printf output file instead of replacing it. A normal start still begins a new file. 4. **loader: show LoadExec switches on the console** — the switch is written to the console as well as the log, with the new program's arguments, so it is clear where one program's output ends and the next one's begins: `LoadExec: switching to /app0/tllr-boot.bin "" "boot-mode-tll"`. ## Evidence Collection `eboot.bin`, The Lost Legacy as the last game played. Console (the launcher's `cmd /K` window) or stdout/stderr redirected to a file: - before: one startup block (the collection's), then nothing; - after: the switch, then the relaunched process's startup block and output, for example the error the relaunched process currently stops with on `main`: ``` Title ID: PPSA05389 Unresolved import stub called: DK+GoXCNT04[Http_v1][Http_v1.1][Func] LoadExec: switching to /app0/tllr-boot.bin "" "boot-mode-tll" Initialized: Config ... Title ID: PPSA05389 Unresolved import stub called: LibwuIonIBw[VideoOutVrrStatus_v1][VideoOut_v1.1][Func] --- Fatal Error --- Error: condition (!Active()) is true in .../commandScheduler.cpp:325 ``` (That error is a separate issue; starting `tllr-boot.bin` directly with `--guest-exec` shows the same error. These changes only make it visible.) `--printf-direction File --printf-output-file log.txt` (file pre-filled with an old line): - before: only the relaunched program's lines; - after: the old line is gone (a normal start still replaces the file), the collection's lines run up to `LoadExec: switching to /app0/tllr-boot.bin "" "boot-mode-tll"`, and the relaunched program's lines follow it, through the error above. ## Testing - Windows 11, RTX 4070, from the command line: console, redirected stdout/stderr and `--printf-direction File`, as above. - From the launcher: the relaunched program's output continues in the launcher's console, and `_kyty.txt` holds both programs' output. > This needs to be tested on Linux and macOS ## AI use These changes were developed with an AI coding assistant
LoadExec on Windows starts a new emulator process and exits the current
one. The new process was created without a console and without the
standard handles, so everything it printed was lost: a redirected log of
a game that relaunches itself ended at the relaunch.

Hand the new process the standard input, output and error handles,
inheriting only those, and let it share the console when there is one.
On Windows, LoadExec flushed the C streams only after the new process
had been created, so output the old process still held could appear
after the new one's first lines. On Linux they were not flushed at all
before exec, which discards them.

Flush the log and every stream before starting the new program.
With --printf-direction File, the program LoadExec starts is given the
same --printf-output-file and opened it anew, emptying it. Everything
the first program had logged, its LoadExec line included, was lost.

LoadExec now sets KYTY_RELAUNCHED for the program it starts, which then
appends to the log file instead of replacing it. On Linux the variable
goes into the environment passed to exec rather than this process's
own, which other threads may be reading.
LoadExec logged the program it switched to only when guest output was
logged, and then only into the log: on a console the new program's
startup output followed the old one's without anything marking where
one program ended and the next began.

Write the switch to the console as well as the log, with the program's
arguments.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:57:41 +00:00
github manually merged commit dd24ee6419 into gh-pr/1480/base 2026-11-26 09:57:41 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-13 16:57 UTC · original

Review in Change Stack →

📝 Walkthrough

LoadExec now logs the target path and arguments, flushes output, and configures relaunch behavior on Windows and Linux. It sets a relaunch environment variable for the new process. The file logger checks that variable and appends to the existing log when it is present; otherwise, it truncates the file.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Bug fix

Merge Risk: 🔵 Low · up to dd24e

The relaunch change preserves output and logs across LoadExec. In a rare failure to set the relaunch marker, the previous log could be truncated. This is a small, low-risk follow-up.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
Description check Passed The description directly explains the LoadExec output, log preservation, flushing, handle inheritance, and testing for the changeset.
Title check Passed The title clearly and concisely identifies the main change: preserving game output and logs across LoadExec relaunches.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-13 16:57 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1480#issuecomment-6150749038) <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1480?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> `LoadExec` now logs the target path and arguments, flushes output, and configures relaunch behavior on Windows and Linux. It sets a relaunch environment variable for the new process. The file logger checks that variable and appends to the existing log when it is present; otherwise, it truncates the file. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"dd24ee6419845fd8073b2d258641733951b2707d" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>🔵 Low</strong> · up to <code>dd24e</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🔵 Low** · up to `dd24e` --> <!-- final_review_risk_coverage:{"sourceCommitId":"dd24ee6419845fd8073b2d258641733951b2707d","coveredCommitId":"dd24ee6419845fd8073b2d258641733951b2707d","kind":"reviewed"} --> The relaunch change preserves output and logs across LoadExec. In a rare failure to set the relaunch marker, the previous log could be truncated. This is a small, low-risk follow-up. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks (1 warning)</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks (4 passed)</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------ | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the LoadExec output, log preservation, flushing, handle inheritance, and testing for the changeset. | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely identifies the main change: preserving game output and logs across LoadExec relaunches. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1480)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
@ -93,0 +134,4 @@
const DWORD flags = (listed ? EXTENDED_STARTUPINFO_PRESENT : 0u) |
(GetConsoleWindow() != nullptr ? 0u : static_cast<DWORD>(CREATE_NO_WINDOW));
// The new process continues this one's log file; it inherits the environment.
(void)SetEnvironmentVariableA(Log::RelaunchedVariable, "1");
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-13 16:57 UTC · original

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '95,160p' src/loader/loadExec.cpp

Repository: KytyPS5/KytyPS5

Length of output: 3213


🏁 Script executed:

rg -n -F --glob '*.{cpp,h,hpp}' -e 'RelaunchedVariable' -e 'MakeFileLogger' -e 'KYTY_RELAUNCHED' -e 'printf' src
printf '\n--- logger definitions/usages ---\n'
rg -n -F --glob '*.{cpp,h,hpp}' -e 'MakeFileLogger' -e 'RelaunchedVariable' src/loader src | head -120
printf '\n--- nearby logger source ---\n'
rg -n -F --glob '*.{cpp,h,hpp}' -e 'class FileLogger' -e 'FileLogger' -e 'OpenFile' -e 'append' src | head -160

Repository: KytyPS5/KytyPS5

Length of output: 32133


🏁 Script executed:

rg -n -F --glob '*.{cpp,h,hpp}' -e 'RelaunchedVariable' -e 'MakeFileLogger' -e 'KYTY_RELAUNCHED' src
printf '\n--- logger definitions/usages ---\n'
rg -n -F --glob '*.{cpp,h,hpp}' -e 'MakeFileLogger' -e 'RelaunchedVariable' src/loader src | head -120
printf '\n--- nearby logger source ---\n'
rg -n -F --glob '*.{cpp,h,hpp}' -e 'class FileLogger' -e 'FileLogger' -e 'OpenFile' -e 'append' src | head -160

Repository: KytyPS5/KytyPS5

Length of output: 8328


🏁 Script executed:

rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'RelaunchedVariable' src
rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'MakeFileLogger' src
rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'KYTY_RELAUNCHED' .

Repository: KytyPS5/KytyPS5

Length of output: 848


🏁 Script executed:

set +e
rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' -- 'RelaunchedVariable' src
rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' -- 'MakeFileLogger' src
rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' -- 'KYTY_RELAUNCHED' .
exit 0

Repository: KytyPS5/KytyPS5

Length of output: 848


🏁 Script executed:

sed -n '35,108p' src/common/logging/log.cpp

Repository: KytyPS5/KytyPS5

Length of output: 2254


Abort only when a new relaunch marker cannot be set.

"KYTY_RELAUNCHED" and "1" are valid, but SetEnvironmentVariableA can still fail when the environment block or system resources are exhausted. If the marker was absent and the call fails, CreateProcessW inherits the missing marker. MakeFileLogger then opens the file with truncation enabled and can discard the previous program's log.

If the marker already exists, preserve the current best-effort relaunch because MakeFileLogger checks only whether the variable exists.

🐛 Suggested fix
--- "a/src/loader/loadExec.cpp"
+++ "b/src/loader/loadExec.cpp"
@@ -133,9 +133,17 @@
 	// A process with a console shares it with the new one; without one, none is created.
 	const DWORD flags = (listed ? EXTENDED_STARTUPINFO_PRESENT : 0u) |
 	                    (GetConsoleWindow() != nullptr ? 0u : static_cast<DWORD>(CREATE_NO_WINDOW));
 	// The new process continues this one's log file; it inherits the environment.
-	(void)SetEnvironmentVariableA(Log::RelaunchedVariable, "1");
+	const bool marker_was_absent = std::getenv(Log::RelaunchedVariable) == nullptr;
+	if (!SetEnvironmentVariableA(Log::RelaunchedVariable, "1") && marker_was_absent) {
+		const auto error = GetLastError();
+		LOGF("LoadExec: setting relaunch marker failed: %lu\n", error);
+		if (inherit) {
+			DeleteProcThreadAttributeList(attributes);
+		}
+		return SYSTEM_SERVICE_ERROR_INTERNAL;
+	}
 	PROCESS_INFORMATION process {};
 	const bool          created =
 	    CreateProcessW(executable, command.data(), nullptr, nullptr, listed ? TRUE : FALSE, flags,
 	                   nullptr, nullptr, &startup.StartupInfo, &process) != 0;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

	const bool marker_was_absent = std::getenv(Log::RelaunchedVariable) == nullptr;
	if (!SetEnvironmentVariableA(Log::RelaunchedVariable, "1") && marker_was_absent) {
		const auto error = GetLastError();
		LOGF("LoadExec: setting relaunch marker failed: %lu\n", error);
		if (inherit) {
			DeleteProcThreadAttributeList(attributes);
		}
		return SYSTEM_SERVICE_ERROR_INTERNAL;
	}
**@⁠coderabbitai[bot]** on GitHub · 2026-10-13 16:57 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1480#discussion_r4261570819) **🗄️ Data Integrity & Integration** | **🟡 Minor** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash sed -n '95,160p' src/loader/loadExec.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 3213 --- 🏁 Script executed: ```bash rg -n -F --glob '*.{cpp,h,hpp}' -e 'RelaunchedVariable' -e 'MakeFileLogger' -e 'KYTY_RELAUNCHED' -e 'printf' src printf '\n--- logger definitions/usages ---\n' rg -n -F --glob '*.{cpp,h,hpp}' -e 'MakeFileLogger' -e 'RelaunchedVariable' src/loader src | head -120 printf '\n--- nearby logger source ---\n' rg -n -F --glob '*.{cpp,h,hpp}' -e 'class FileLogger' -e 'FileLogger' -e 'OpenFile' -e 'append' src | head -160 ``` Repository: KytyPS5/KytyPS5 Length of output: 32133 --- 🏁 Script executed: ```bash rg -n -F --glob '*.{cpp,h,hpp}' -e 'RelaunchedVariable' -e 'MakeFileLogger' -e 'KYTY_RELAUNCHED' src printf '\n--- logger definitions/usages ---\n' rg -n -F --glob '*.{cpp,h,hpp}' -e 'MakeFileLogger' -e 'RelaunchedVariable' src/loader src | head -120 printf '\n--- nearby logger source ---\n' rg -n -F --glob '*.{cpp,h,hpp}' -e 'class FileLogger' -e 'FileLogger' -e 'OpenFile' -e 'append' src | head -160 ``` Repository: KytyPS5/KytyPS5 Length of output: 8328 --- 🏁 Script executed: ```bash rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'RelaunchedVariable' src rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'MakeFileLogger' src rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' 'KYTY_RELAUNCHED' . ``` Repository: KytyPS5/KytyPS5 Length of output: 848 --- 🏁 Script executed: ```bash set +e rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' -- 'RelaunchedVariable' src rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' -- 'MakeFileLogger' src rg -n -F --glob '*.cpp' --glob '*.h' --glob '*.hpp' -- 'KYTY_RELAUNCHED' . exit 0 ``` Repository: KytyPS5/KytyPS5 Length of output: 848 --- 🏁 Script executed: ```bash sed -n '35,108p' src/common/logging/log.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 2254 --- </details> **Abort only when a new relaunch marker cannot be set.** `"KYTY_RELAUNCHED"` and `"1"` are valid, but `SetEnvironmentVariableA` can still fail when the environment block or system resources are exhausted. If the marker was absent and the call fails, `CreateProcessW` inherits the missing marker. `MakeFileLogger` then opens the file with truncation enabled and can discard the previous program's log. If the marker already exists, preserve the current best-effort relaunch because `MakeFileLogger` checks only whether the variable exists. <details> <summary>🐛 Suggested fix</summary> ```diff --- "a/src/loader/loadExec.cpp" +++ "b/src/loader/loadExec.cpp" @@ -133,9 +133,17 @@ // A process with a console shares it with the new one; without one, none is created. const DWORD flags = (listed ? EXTENDED_STARTUPINFO_PRESENT : 0u) | (GetConsoleWindow() != nullptr ? 0u : static_cast<DWORD>(CREATE_NO_WINDOW)); // The new process continues this one's log file; it inherits the environment. - (void)SetEnvironmentVariableA(Log::RelaunchedVariable, "1"); + const bool marker_was_absent = std::getenv(Log::RelaunchedVariable) == nullptr; + if (!SetEnvironmentVariableA(Log::RelaunchedVariable, "1") && marker_was_absent) { + const auto error = GetLastError(); + LOGF("LoadExec: setting relaunch marker failed: %lu\n", error); + if (inherit) { + DeleteProcThreadAttributeList(attributes); + } + return SYSTEM_SERVICE_ERROR_INTERNAL; + } PROCESS_INFORMATION process {}; const bool created = CreateProcessW(executable, command.data(), nullptr, nullptr, listed ? TRUE : FALSE, flags, nullptr, nullptr, &startup.StartupInfo, &process) != 0; ``` </details> <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. ```suggestion const bool marker_was_absent = std::getenv(Log::RelaunchedVariable) == nullptr; if (!SetEnvironmentVariableA(Log::RelaunchedVariable, "1") && marker_was_absent) { const auto error = GetLastError(); LOGF("LoadExec: setting relaunch marker failed: %lu\n", error); if (inherit) { DeleteProcThreadAttributeList(attributes); } return SYSTEM_SERVICE_ERROR_INTERNAL; } ``` </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:medusa:beignet55 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:4ed7e959f96c5911f46f3601 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-13 16:57 UTC · original · reviewed

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c00ebcb4-946d-4e64-992f-e599091bccd3
📥 Commits

Reviewing files that changed from the base of the PR and between df5b9b92be and dd24ee6419.

📒 Files selected for processing (3)
  • src/common/logging/log.cpp
  • src/common/logging/log.h
  • src/loader/loadExec.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-13 16:57 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1480#pullrequestreview-5507103817) · **reviewed** **Actionable comments posted: 1** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `c00ebcb4-946d-4e64-992f-e599091bccd3` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between df5b9b92be7dfd463b47756b707d6d356a9f0550 and dd24ee6419845fd8073b2d258641733951b2707d. </details> <details> <summary>📒 Files selected for processing (3)</summary> * `src/common/logging/log.cpp` * `src/common/logging/log.h` * `src/loader/loadExec.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=237e5a06-3f03-4ea0-a2ea-ff31c5648d1f attempt=ec62f490-bbdb-4438-935b-f419ec5a98b3 batch=1/1 -->
Author
Owner

@⁠Nmzik on GitHub · 2026-10-16 01:01 UTC · original

@⁠Almo7aya Thanks

**@⁠Nmzik** on GitHub · 2026-10-16 01:01 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1480#issuecomment-6205611671) @⁠Almo7aya Thanks
This discussion has been locked. Commenting is limited to contributors.
No description provided.