Skip to content

[PHP] fix: raise SIGPIPE for bridged TCP EPIPE#749

Merged
brandonpayton merged 2 commits into
integration/kd-6nz-php-phpt-batch-1-kernel-fixesfrom
gascity/kd-6nz/split-pr717-tcp-epipe-sigpipe
Jul 10, 2026
Merged

[PHP] fix: raise SIGPIPE for bridged TCP EPIPE#749
brandonpayton merged 2 commits into
integration/kd-6nz-php-phpt-batch-1-kernel-fixesfrom
gascity/kd-6nz/split-pr717-tcp-epipe-sigpipe

Conversation

@brandonpayton

@brandonpayton brandonpayton commented Jun 20, 2026

Copy link
Copy Markdown
Member

Why

POSIX requires that writing to a stream socket whose peer has closed the read end returns EPIPE and raises SIGPIPE, unless the caller opts out with MSG_NOSIGNAL (or SO_NOSIGPIPE). Kandelo's in-kernel pipe-backed sockets already did this, but the host-bridged TCP path (host_net_send for AF_INET/AF_INET6) only propagated the EPIPE errno and never raised the signal — and it did not honor MSG_NOSIGNAL. So PHP stream/socket tests saw non-Unix behavior that depended on whether a connection was loopback or host-bridged.

Making the bridged path match the in-kernel socket model is a platform fix that benefits every package using bridged TCP, not just PHP.

What

  • crates/kernel/src/syscalls.rs: in sys_write's external-TCP branch, map an EPIPE from host_net_send to raising SIGPIPE (mirroring the pipe-backed path). In sys_send, honor MSG_NOSIGNAL — suppress the SIGPIPE a write would raise, and on the external path raise SIGPIPE on EPIPE only when MSG_NOSIGNAL is unset.
  • Extends MockHostIO so host_net_connect / connect_status / send / listen results are configurable, and adds tests: external-TCP EPIPE raises SIGPIPE; send(..., MSG_NOSIGNAL) suppresses it.

Provenance

Supersedes fork-headed PR #729; identical head commit 9e252cfb8d6af2e1dd5c91d61c1357456411b84d, re-pointed onto an Automattic/kandelo branch. No code changed from #729.

The SIGPIPE-on-EPIPE change added a test for external send with MSG_NOSIGNAL
(signal suppressed) but not for external send with default flags, which is the
main new branch in sys_send. Add that case, and record the observable behavior
in docs/posix-status.md: a send to a broken stream peer returns EPIPE and
raises SIGPIPE across host-bridged external and loopback TCP, with MSG_NOSIGNAL
suppressing the signal.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@brandonpayton
brandonpayton changed the base branch from integration/kd-6nz-php-phpt-harness-only-base to integration/kd-6nz-php-phpt-batch-1-kernel-fixes July 10, 2026 17:03
@brandonpayton
brandonpayton merged commit f644474 into integration/kd-6nz-php-phpt-batch-1-kernel-fixes Jul 10, 2026
1 check passed
@brandonpayton
brandonpayton deleted the gascity/kd-6nz/split-pr717-tcp-epipe-sigpipe branch July 10, 2026 17:04
brandonpayton pushed a commit that referenced this pull request Jul 13, 2026
Delivering SIGPIPE for this existing EPIPE path changes observable signal and default-termination semantics. Advance ABI 18 to 19 and regenerate the ABI evidence in the same commit.

Source-PR: #749

Folded coverage and documentation: a9652e91c.
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