Repository navigation
Conversation
f38eb17 to
4a5d009
Compare
There was a problem hiding this comment.
I couldn't verify this. The change only affects Windows and needs Store PowerShell 7, and the review sandbox is Linux with no Rust toolchain, so I reviewed it by reading the code only.
The approach looks right to me. Setting PROC_THREAD_ATTRIBUTE_DESKTOP_APP_POLICY with the disable-breakaway bit on the pipe spawn is the documented way to keep children of packaged apps inside the job. It sits next to the existing handle-list attribute, and the list is sized from the number of entries. The 1703+ requirement is within the daemon's existing Windows 10 1709+ minimum (README), so older systems don't lose anything. The new test returns early where Store PowerShell is missing, and it is a small, direct check of the fix.
Public API: unchanged. This is internal to the daemon's Windows spawn path.
No blocking concerns.
Related: #57813
4a5d009 to
1ab808e
Compare
There was a problem hiding this comment.
Rebased onto dev only. The PR's commit is identical to what I reviewed before, so I have no new concerns. I still couldn't run it: it only affects Windows (Store PowerShell), and this sandbox is Linux with no Rust toolchain. Public API: unchanged.
There was a problem hiding this comment.
The new commit only updates the docs: SPEC.md and the comment on the policy constant now say that a Store app started by another process in the job (e.g. cmd.exe running pwsh) still breaks away. That matches the description's "Not covered" section. The code is unchanged, and I have no new concerns. I still couldn't run this: it needs Windows with Store PowerShell. Public API: unchanged.
Issue for this PR
Follow-up to #64803 and #64901 (merged).
Type of change
What does this PR do?
With Store PowerShell 7 as the shell, every program a command starts (
git,bun test, a dev server, a plainping) is in no job at all. So cancelling or timing out a shell command kills onlypwsh, and the programs it started keep running. A daemon crash leaves them behind too.The cause is how Windows handles packaged desktop apps. By default a Store app's children "break away" from the app's package environment, and with it from every job, including the daemon's. The children keep
pwshas their parent but have no package identity and no job. This happens ondevand with #64901.Windows has a process attribute for exactly this,
PROC_THREAD_ATTRIBUTE_DESKTOP_APP_POLICY(Windows 10 1703+). WithPROCESS_CREATION_DESKTOP_APP_BREAKAWAY_DISABLE_PROCESS_TREE(0x02, not defined inwindows-sys), the children stay inside the package's environment, and so in our kill-on-close job. This covers how OpenCode runs commands, since the shell tool passes Storepwshto the daemon as the program. For programs that aren't packaged it has no effect.Tradeoff: children of Store
pwshnow run with the PowerShell package's identity. The PowerShell package turns off file-system and registry write virtualization in its manifest, so their writes still go to the real locations (checked below).How did you verify your code works?
On Windows 11 with Store PowerShell 7.7.0:
signal_reaches_a_grandchild_of_store_powershelltotests/pipe_windows.rs. It goes throughTerminalService: Storepwshstartsping.exe, the command is killed, andpingmust die. It fails without this change (process ... is still running) and passes with it. It returns early where Store PowerShell isn't installed, as on CI.pwshis now in a job. Inside such a command:winget,git,nodeandbunall work.%LOCALAPPDATA%,%TEMP%andHKCU\Softwarelanded in the real locations, seen from outside.pwshcommands running, killing one kills only its own child.cargo fmt --check,cargo clippy --all-targets --all-features -- -D warningsandcargo testinpackages/process-daemonall pass.Not covered here, fixed in #65141 (stacked on this PR): a Store app started further down the tree, e.g.
cmd.exeor Windows PowerShell running Storepwsh. Storepwshthen breaks away itself, along with its children. Checked through the daemon: this is the same ondevand with this change.The PTY (interactive terminal) path doesn't set this attribute, and doesn't need to. A Store
pwshterminal behaves like one running regularpwsh: closing it kills everything attached to the console.No flag: this is a fix in the daemon's spawn path.
Screenshots / recordings
Not a UI change.
Checklist
Added by the opencode bot (AI-generated).
Related: #57813