-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Revert "Use socketpair to implement Process.Start redirection (#34861)" #40832
Revert "Use socketpair to implement Process.Start redirection (#34861)" #40832
Conversation
Tagging subscribers to this area: @eiriktsarpalis |
If we go ahead with this reverting, we need to have an issue to redo it in .NET 6.0. This was fixing a real issue. |
(I'd also love it if we could do a bit more debugging and see whether there's a simple fix that would enable this to work in WSL1, such as being a bit more forgiving of various error conditions.) |
How about not reverting it but adding a fallback based on whether to socket is connected or not? private static Stream OpenStream(int fd, FileAccess access)
{
var socket = new Socket(new SafeSocketHandle((IntPtr)fd, ownsHandle: true));
if (socket.IsConnected)
{
return new NetworkStream(socket, access, ownsSocket: true);
}
else //WSL1
{
return new FileStream(
new SafeFileHandle((IntPtr)fd, ownsHandle: true),
access, StreamBufferSize, isAsync: false);
}
} @stephentoub @eiriktsarpalis what do you think? |
Thanks, Adam. My preference would be to actually fix the Socket ctor; both reverting this and working around it in Process will still leave the ctor buggy in WSL1 for any other consumption. But short of that, yes, I'd prefer a (temporary) workaround in Process rather than reverting. (But note a workaround like above would be a little more complicated, e.g. the FileStream would need to keep the Socket alive.) |
Do we have reliable platform detection for WSL1? We could just use that to switch to the old implementation. |
same here
The problem is that it can also occur on other Unixes, like |
I don't believe this is really possible at the socket layer for WSL1. We'd need to somehow infer the address family and there's a lot of other weird behaviour going on, for instance calling For the fallback logic, it might make sense to do some form of platform detection for WSL1. The best known approach is reading the cc @wfurt |
@eiriktsarpalis, did you debug into
|
Sure, it looks like the |
Presumably -1. Can you see what errno is? |
It's EINVAL. |
Thanks. I suspect the right fix is to be more forgiving of such errors, as we do later in the method: runtime/src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs Lines 220 to 226 in 12f8e34
|
Closing in favor of #40851 |
Reverts commit c44dc40, introduced by #34861.
Fixes #40727.
Please don't merge while I test the changes in WSL1.