Skip to content

fix(process-session): spawn the same command more than once - #80

Merged
passcod merged 2 commits into
mainfrom
fix/process-session-respawn
Nov 11, 2026
Merged

passcod merged 2 commits into
mainfrom
fix/process-session-respawn

Conversation

@passcod

@passcod passcod commented Nov 11, 2026

Copy link
Copy Markdown
Member

🤖 A CommandWrap keeps its command across spawns and runs every wrapper's pre_spawn again on each one. pre_exec only ever adds hooks, so a command with ProcessSession runs setsid() once per spawn so far. On the second spawn, the second call fails with EPERM and the spawn errors out. This affects both frontends.

The hook now treats EPERM as success when the child already leads its session. ProcessSession is a public unit struct, so it can't remember that it already installed its hook without a breaking change. That means hooks still pile up, one per spawn: the extra ones are cheap syscalls in the child, but a command reused very many times keeps growing its hook list. ResetSigmask piles up the same way, and its hooks were already harmless to repeat.

Adds tests that spawn the same command twice with each Unix wrapper.

@passcod
passcod marked this pull request as ready for review November 11, 2026 02:15
@passcod
passcod force-pushed the fix/process-session-respawn branch from 4de3e70 to 64abb09 Compare November 11, 2026 02:15
A command keeps its pre_exec hooks and pre_spawn runs on every spawn, so a
second spawn ran setsid() twice in the child, and the second call failed
with EPERM. The hook now accepts EPERM when the child already leads its
session.
@passcod
passcod force-pushed the fix/process-session-respawn branch from 64abb09 to a64e7a9 Compare November 11, 2026 02:15
@codecov

codecov Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 20.00000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.32%. Comparing base (ff2ab66) to head (a64e7a9).

Files with missing lines Patch % Lines
src/std/process_session.rs 20.00% 4 Missing ⚠️
src/tokio/process_session.rs 20.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #80      +/-   ##
==========================================
+ Coverage   84.22%   84.32%   +0.09%     
==========================================
  Files          17       17              
  Lines        1268     1276       +8     
==========================================
+ Hits         1068     1076       +8     
  Misses        200      200              
Flag Coverage Δ
macos 80.34% <20.00%> (+1.05%) ⬆️
ubuntu 80.40% <20.00%> (+0.18%) ⬆️
windows 88.48% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@passcod
passcod merged commit 97e4c6d into main Nov 11, 2026
23 of 24 checks passed
@passcod
passcod deleted the fix/process-session-respawn branch November 11, 2026 02:30
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