Skip to content

Conversation

@jakepetroules
Copy link
Member

FileDescriptor.duplicate(as:) is backed by dup2 on Unix, and _dup2 on Windows. On Unix, dup2 returns its second argument. On Windows, _dup2 instead returns 0 on success and -1 on error. This results in the newly returned FileDescriptor object always containing a '0' file descriptor rather than the newly created file descriptor, in violation of the documented behavior.

Account for the platform difference in the syscall wrapper to fix this.

Closes #192

(cherry picked from commit b2711a8)

…riptor on Windows

FileDescriptor.duplicate(as:) is backed by dup2 on Unix, and _dup2 on Windows.
On Unix, dup2 returns its second argument. On Windows, _dup2 instead returns
0 on success and -1 on error. This results in the newly returned FileDescriptor
object always containing a '0' file descriptor rather than the newly created
file descriptor, in violation of the documented behavior.

Account for the platform difference in the syscall wrapper to fix this.

Closes #192

(cherry picked from commit b2711a8)
@glessard glessard merged commit 395a77f into release/1.6.0 Sep 15, 2025
40 checks passed
@glessard glessard deleted the eng/PR-duplicate-as-release/1.6.0 branch September 15, 2025 17:36
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.

3 participants