Skip to content

fix(process): skip wait/exit_code when prep-cmd fails with permission_denied in desktop mode#680

Open
Han-cy830 wants to merge 1 commit into
AlkaidLab:masterfrom
Han-cy830:fix/prep-cmd-skip-on-permission-denied
Open

fix(process): skip wait/exit_code when prep-cmd fails with permission_denied in desktop mode#680
Han-cy830 wants to merge 1 commit into
AlkaidLab:masterfrom
Han-cy830:fix/prep-cmd-skip-on-permission-denied

Conversation

@Han-cy830
Copy link
Copy Markdown

Summary

  • Fix incomplete permission_denied exception handling in proc_t::execute() prep-cmd loop
  • When running in desktop mode (app.cmd is empty) and a prep-cmd fails with permission_denied (e.g., Session 0 isolation when screen is locked), the existing code already skips the run_command error. However, the subsequent child.wait() also returns permission_denied, which was not covered by the exception and caused execute() to return -1, triggering fail_guard to destroy the VDD and break streaming.

Root Cause

In the original code:

if (ec) {
    // ... skip permission_denied in desktop mode ✓
}
child.wait(ec);  // ← also returns permission_denied, NOT skipped ✗
if (ec) {
    return -1;  // ← triggers fail_guard → VDD destroyed → streaming breaks
}

Fix

Add a skip_prep_failure flag that, when set, also skips the wait() and exit_code() checks:

bool skip_prep_failure = false;
if (ec) {
    if (_app.cmd.empty() && ec == std::errc::permission_denied) {
        skip_prep_failure = true;
    } else {
        return -1;
    }
}
if (!skip_prep_failure) {
    child.wait(ec);
    // ... exit_code check
}

Testing

  • Verified on Windows 11 with Sunshine running as SYSTEM service
  • Unlocked screen: prep-cmd (SetDpi.exe) executes normally, DPI switching works
  • Locked screen: prep-cmd fails with permission_denied but is skipped, streaming starts successfully (no DPI switching, as expected)
  • Log confirms: Couldn't run [.\tools\SetDpi.exe 175]: System: permission_denied followed by successful [Desktop] execution

Files Changed

  • src/process.cppproc_t::execute() prep-cmd loop only

…_denied in desktop mode

When running in desktop mode (app.cmd is empty) and a prep-cmd fails with
permission_denied (e.g., Session 0 isolation when screen is locked), the
existing code already skips the run_command error. However, the subsequent
child.wait() also returns permission_denied, which was NOT covered by the
exception and caused execute() to return -1, triggering fail_guard to
destroy the VDD and break streaming.

This fix adds a skip_prep_failure flag that, when set, also skips the
wait() and exit_code() checks, allowing the streaming session to continue
normally even when prep-cmds fail due to locked screen.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0dfdde47-80b9-4674-b06c-edb60ecbdbd4

📥 Commits

Reviewing files that changed from the base of the PR and between 1bee5cb and 0639fa8.

📒 Files selected for processing (1)
  • src/process.cpp
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (1)
src/**/*.{cpp,c,h}

⚙️ CodeRabbit configuration file

src/**/*.{cpp,c,h}: Sunshine 核心 C++ 源码,自托管游戏串流服务器。审查要点:内存安全、 线程安全、RAII 资源管理、安全漏洞。注意预处理宏控制的平台相关代码。

Files:

  • src/process.cpp
🔇 Additional comments (1)
src/process.cpp (1)

246-248: LGTM!

Also applies to: 254-256, 261-271


Summary by CodeRabbit

发布说明

  • Bug Fixes
    • 优化了桌面模式下预启动命令的权限异常处理,防止权限拒绝错误导致应用启动失败。

总览

proc_t::execute() 在执行预启动命令时新增了桌面模式下权限拒绝错误的特殊处理,通过引入 skip_prep_failure 标志来条件性地跳过进程等待和退出码验证步骤,避免该特定异常导致提前返回失败。

变更

预启动命令权限异常处理

层级 / 文件 摘要
预启动命令权限拒绝跳过机制
src/process.cpp
proc_t::execute() 的预启动阶段新增 skip_prep_failure 局部变量,当 platf::run_command 返回权限拒绝错误且应用命令为空(桌面模式)时,设置此标志以跳过后续的 wait()exit_code() 失败处理;其他错误情况仍保持原有的错误返回行为。

预期审查工作量

🎯 3 (中等) | ⏱️ ~20 分钟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确总结了主要变更:在桌面模式下当 prep-cmd 因权限拒绝而失败时跳过 wait/exit_code 检查,与 src/process.cpp 中的变更内容高度相关。
Description check ✅ Passed 描述详细说明了问题根源、解决方案、代码示例和测试验证,完全相关于 src/process.cpp 中的变更,提供了充分的上下文信息。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@qiin2333 qiin2333 force-pushed the master branch 2 times, most recently from 4db4aa3 to e5579b9 Compare June 4, 2026 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant