Repository navigation
fix(platform): only request CREATE_BREAKAWAY_FROM_JOB when the job allows it - #1325
Conversation
…lows it CreateProcess fails with ERROR_ACCESS_DENIED (os error 5) when the caller lives in a job without JOB_OBJECT_LIMIT_BREAKAWAY_OK, e.g. the Desktop shell started under AppX activation, so `codexhost launch` could not start at all. Probe job membership and breakaway permission first and request the breakaway only when it is safe; otherwise start the detached service nested in the caller's job instead of failing.
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
|
感谢贡献!在共享的 |
Summary
codexhost launch由 Desktop shell 拉起时可能直接失败,报Cannot run+ "codexhost launch" +: 拒绝访问 (os error 5)。根因:Windows
CreateProcess在调用方进程位于一个未设置JOB_OBJECT_LIMIT_BREAKAWAY_OK的 Job(例如 AppX 激活或其它外部 Job 下的 shell 进程)时,会拒绝CREATE_BREAKAWAY_FROM_JOB请求并返回ERROR_ACCESS_DENIED,进程根本不会启动。configure_detached_service_command此前无条件附加该 flag,遇到这类环境必然失败。修复:spawn 前用
IsProcessInJob+QueryInformationJobObject探测当前 Job 是否允许 breakaway——不在任何 Job 中(flag 是 no-op)或 Job 明确允许时才附加CREATE_BREAKAWAY_FROM_JOB;否则不带该 flag 启动,分离出来的服务嵌套在调用方 Job 中,而不是让整个启动失败。Related issues
fixes #1321
UI Demo
No visual changes: 仅调整 Windows 进程启动 flag 的探测逻辑,无 UI 改动。
Test plan
cargo check -p codexhost-platform(linux,通过)cargo clippy -p codexhost-platform --all-targets -- -D warnings(linux,通过,0 warning)rustup target add x86_64-pc-windows-msvc后cargo check -p codexhost-platform --target x86_64-pc-windows-msvc(通过)与cargo clippy -p codexhost-platform --target x86_64-pc-windows-msvc --all-targets -- -D warnings(通过,0 warning)