Add overloads to cover dup3 and pipe2 POSIX APIs#266
Open
jakepetroules wants to merge 1 commit intomainfrom
Open
Add overloads to cover dup3 and pipe2 POSIX APIs#266jakepetroules wants to merge 1 commit intomainfrom
jakepetroules wants to merge 1 commit intomainfrom
Conversation
66bc4e3 to
3d98a84
Compare
This follows the existing pattern of wrapping dup/dup2 and pipe with FileDescriptor.duplicate and FileDescriptor.pipe, with additional overloads for passing the O_CLOEXEC and similar flags.
3d98a84 to
c69bf50
Compare
Member
Author
|
@swift-ci test |
glessard
reviewed
Oct 7, 2025
Contributor
glessard
left a comment
There was a problem hiding this comment.
Thanks for this contribution!
| try _duplicate(as: target, options: options.rawValue, retryOnInterrupt: retryOnInterrupt).get() | ||
| } | ||
|
|
||
| @available(System 0.0.2, *) |
Contributor
There was a problem hiding this comment.
A @usableFromInline symbol requires availability.
| try _pipe(options: options.rawValue).get() | ||
| } | ||
|
|
||
| @available(System 1.1.0, *) |
Contributor
There was a problem hiding this comment.
As above, @usableFromInline symbols require availability.
| @usableFromInline | ||
| internal func _duplicate( | ||
| as target: FileDescriptor?, | ||
| options: Int32, |
Contributor
There was a problem hiding this comment.
We shouldn't remove the old @usableFromInline symbol; it could be re-implemented by forwarding to the new implementation.
| @available(System 1.1.0, *) | ||
| @usableFromInline | ||
| internal static func _pipe() -> Result<(readEnd: FileDescriptor, writeEnd: FileDescriptor), Errno> { | ||
| internal static func _pipe(options: Int32) -> Result<(readEnd: FileDescriptor, writeEnd: FileDescriptor), Errno> { |
| retryOnInterrupt: Bool = true | ||
| ) throws -> FileDescriptor { | ||
| try _duplicate(as: target, retryOnInterrupt: retryOnInterrupt).get() | ||
| try _duplicate(as: target, options: 0, retryOnInterrupt: retryOnInterrupt).get() |
Contributor
There was a problem hiding this comment.
The package version that will include this drops support for Swift toolchains older than 6.0. We could therefore make these @_aEIC entry points use typed throws, i.e. throws(ErrNo).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This follows the existing pattern of wrapping dup/dup2 and pipe with FileDescriptor.duplicate and FileDescriptor.pipe, with additional overloads for passing the O_CLOEXEC and similar flags.
Forums pitch: https://forums.swift.org/t/pitch-swiftsystem-dup3-and-pipe2-cover-apis/
Addresses: #228