Skip to content

Conversation

@panjf2000
Copy link
Contributor

Before this PR, pipe2() is only enabled on Linux and FreeBSD while pipe2() is available on *BSD.

This PR enables pipe2() for the rest of *BSD: DragonFlyBSD, NetBSD and OpenBSD.

Before this PR, `pipe2()` is only enabled on Linux and FreeBSD while `pipe2()` is available on *BSD.

This PR enables `pipe2()` for the rest of *BSD: DragonFlyBSD, NetBSD and OpenBSD.

- [pipe2 on DraonFlyBSD](https://man.dragonflybsd.org/?command=pipe&section=2)
- [__DragonFly_version for pipe2](https://github.com/DragonFlyBSD/DragonFlyBSD/blob/7485684fa5c3fadb6c7a1da0d8bb6ea5da4e0f2f/sys/sys/param.h#L121)
- [pipe2 on  NetBSD](https://man.netbsd.org/pipe.2)
- [pipe2 on OpenBSD](https://man.openbsd.org/pipe.2)
Copy link
Collaborator

@skaslev skaslev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OTOH all of those *BSD added pipe2() more than 10 years ago.
The same is true for FreeBSD and we've been using pipe2() unconditionally of OS version so far.
Maybe we use pipe2() version unconditionally on all *BSDs; alternatively we can add FreeBSD version check > 10.0 for completeness.
@sundb wdyt?

@sundb
Copy link
Collaborator

sundb commented Nov 24, 2025

OTOH all of those *BSD added pipe2() more than 10 years ago. The same is true for FreeBSD and we've been using pipe2() unconditionally of OS version so far. Maybe we use pipe2() version unconditionally on all *BSDs; alternatively we can add FreeBSD version check > 10.0 for completeness. @sundb wdyt?

i'm not sure which way is correct, let's wait for #14558 (comment)

Copy link

@shahsb shahsb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copilot AI review requested due to automatic review settings December 10, 2025 12:47
@panjf2000 panjf2000 requested review from skaslev and sundb December 10, 2025 12:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends pipe2() system call support beyond Linux and FreeBSD to include DragonFlyBSD, NetBSD, and OpenBSD. The changes introduce version-specific detection for these BSD variants and refactor the existing hardcoded platform checks to use a centralized HAVE_PIPE2 macro for better maintainability.

Key Changes:

  • Added version-aware detection for pipe2() availability on OpenBSD (≥5.7), DragonFlyBSD (≥4.0), and NetBSD (≥6.0)
  • Refactored platform-specific conditional from direct __linux__/__FreeBSD__ checks to a centralized HAVE_PIPE2 macro
  • Applied consistent feature detection pattern used elsewhere in the codebase

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/config.h Defines HAVE_PIPE2 macro with version checks for Linux, FreeBSD, OpenBSD, DragonFlyBSD, and NetBSD
src/anet.c Replaces platform-specific conditionals with HAVE_PIPE2 macro check for cleaner code

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

4 participants