-
Notifications
You must be signed in to change notification settings - Fork 124
Add overloads to cover dup3 and pipe2 POSIX APIs #266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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
@swift-ci test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this contribution!
try _duplicate(as: target, options: options.rawValue, retryOnInterrupt: retryOnInterrupt).get() | ||
} | ||
|
||
@available(System 0.0.2, *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A @usableFromInline
symbol requires availability.
try _pipe(options: options.rawValue).get() | ||
} | ||
|
||
@available(System 1.1.0, *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above, @usableFromInline symbols require availability.
@usableFromInline | ||
internal func _duplicate( | ||
as target: FileDescriptor?, | ||
options: Int32, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above.
retryOnInterrupt: Bool = true | ||
) throws -> FileDescriptor { | ||
try _duplicate(as: target, retryOnInterrupt: retryOnInterrupt).get() | ||
try _duplicate(as: target, options: 0, retryOnInterrupt: retryOnInterrupt).get() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 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/