Skip to content

Fix FD leak in POSIX pipe setup and correct write_all_nullptr_case#1201

Merged
trcrsired merged 1 commit into
cppfastio:nextfrom
mq-loser:fix/bugfix
Sep 28, 2025
Merged

Fix FD leak in POSIX pipe setup and correct write_all_nullptr_case#1201
trcrsired merged 1 commit into
cppfastio:nextfrom
mq-loser:fix/bugfix

Conversation

@mq-loser

Copy link
Copy Markdown

This PR fixes two issues in the file/device I/O path:

  • io_buffer write path: correct write_all_nullptr_case to call the proper
    scatter_write_all(_bytes)_decay on the output stream and keep buffer pointers
    consistent.
  • POSIX pipe constructor: avoid FD leaks on error paths by using RAII
    (posix_file_factory) and setting FD_CLOEXEC; make ownership transfer explicit
    and maintain a single assignment point.

Notes:

  • No public API changes; success paths remain unaffected.
  • Linear history preserved (rebase-only).

…pipe setup

- freestanding/io_buffer/output.h: fix write_all_nullptr_case to dispatch to
  scatter_write_all(_bytes)_decay on the output stream (optstm), and keep
  buffer_curr consistent.
- hosted/platforms/posix.h: avoid FD leaks in the POSIX pipe constructor by
  wrapping FDs with posix_file_factory and setting FD_CLOEXEC; transfer
  ownership explicitly and keep a single assignment point.

No API changes. Success paths unchanged. Rebase-only history preserved.
@trcrsired trcrsired merged commit 79919c0 into cppfastio:next Sep 28, 2025
2 checks passed
@mq-loser mq-loser deleted the fix/bugfix branch September 29, 2025 09:17
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.

2 participants