You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On Windows, _dup2 is documented to return 0 to indicate success, in contrast to POSIX's dup2, which returns the new file descriptor.
Should we change the Windows syscall adapter to something like:
@inline(__always)internalfunc dup2(_ fd:Int32, _ fd2:Int32)->Int32{_dup2(fd, fd2)return fd2 // dup2 is documented on windows to return 0 on success while POSIX expects fd2, // so always return fd2 for consistency}
I understand the general spirit of swift-system is to match the platform behavior, but this one stands out as potentially quite surprising, so I wonder if we should at least call it out in the documentation comments for this function?
The text was updated successfully, but these errors were encountered:
The current state of FileDescriptor on Windows is that it's become a questionable POSIX-emulation layer, and it shouldn't be this way. We should have the thinnest possible wrappers over the platform calls, with the translation limited to adapting language differences. Cross-platform behaviour should be implemented by swift-foundation.
On Windows, _dup2 is documented to return 0 to indicate success, in contrast to POSIX's dup2, which returns the new file descriptor.
Should we change the Windows syscall adapter to something like:
I understand the general spirit of swift-system is to match the platform behavior, but this one stands out as potentially quite surprising, so I wonder if we should at least call it out in the documentation comments for this function?
The text was updated successfully, but these errors were encountered: