Skip to content

fix(proc): a standard descriptor closed at start keeps the child's streams - #5

Merged
HaoZeke merged 10 commits into
mainfrom
fix/proc-std-fds
Nov 16, 2026
Merged

HaoZeke merged 10 commits into
mainfrom
fix/proc-std-fds

Conversation

@HaoZeke

@HaoZeke HaoZeke commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

proc.run now gives the child /dev/null or its pipes on fds 0 to 2 when the caller started with one of them closed.

  • When the caller started with fd 0, 1 or 2 closed, /dev/null or a pipe took that number, and childExec's dup2 sequence either clobbered it (fd 1: the child's stderr went to the captured stdout) or made a no-op dup2 onto itself that kept close-on-exec (fd 0 or 2: the child started with that stream closed).
  • Sources below 3 now move above 2 before the dup2s, as Python's _posixsubprocess does.
  • Each test forks, closes the descriptor and checks what the child sees.

The branch has a CHANGELOG Unreleased entry.

fgetxattr was not retried on EINTR, so a signal refused the replacement.
atomicWrite also leaked the temporary path, the step names and the spare
ACL read. Tests cover both under std.testing.allocator.
copyTo renames the new bytes into place, so a full disk or a file-size
limit leaves an existing file unchanged. appendLine rolls a short write
back to the size before it, so the line list does not gain a partial line.
lockExclusive reads its deadline from the monotonic clock, so a signal
that cuts a sleep short does not expire the wait. RootLock refuses a gate
or sidecar that is not a regular file of this user with one link.
decodeCache and key comparison read past a string that ended on a
backslash. They now return an encoding error, and the bytes allocated
before that error are freed.
The list was abandoned on the error path, and the slice it returned was
not the whole allocation, so a caller could not free it.
The archive is written under a temporary name, synced and renamed. A
crash or a short write no longer leaves a partial name.gz that a later
run skips.
groupAlive treated EINTR from getdents as "nobody is alive", so
waitGroupGone could return while the group was still running.
COMPAT.md said errno 134 was the unnamed hardware-error text. On x86_64
that text is errno 133, HWPOISON, which Zig names; 134 is unnamed, as
glibc prints it. The module summary matches the copy and the lock gate.
A caller started with fd 0, 1 or 2 closed gets /dev/null at that number.
With fd 1 closed the child's stderr ends up in the captured stdout; with
fd 0 or 2 closed the child loses that stream at exec. Each test forks,
closes the descriptor and checks what the child sees. They fail until
childExec is fixed.
…reams

When the caller started with fd 0, 1 or 2 closed, /dev/null or a pipe took
that number, and childExec's dup2 sequence either clobbered it (fd 1: the
child's stderr went to the captured stdout) or made a no-op dup2 onto
itself that kept close-on-exec (fd 0 or 2: the child started with that
stream closed). Sources below 3 now move above 2 before the dup2s, as
Python's _posixsubprocess does.
@HaoZeke
HaoZeke merged commit 2745f00 into main Nov 16, 2026
8 checks passed
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