-
Notifications
You must be signed in to change notification settings - Fork 835
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
Redirecting stdin from a file in WSL and calling a Win32 executable causes GetFileSizeEx function to fail #3723
Comments
I like it. You've hit a common pitfall, which exists in Linux too. Consider:
Same problem. You aren't in your local shell anymore, and that This said, I wish what you are trying to do worked. It would work with Cygwin. It could be made to work in WSL. But it would take a very big leap outside the box on how the devs look at the WSL project. Don't have the heart to close by-design. Fun post, thanks. |
I'm fine if this isn't supported/by-design but if that is the case, should GetFileType be returning FILE_TYPE_DISK? The documentation for GetFileSize (https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfilesize) states:
Although it doesn't explicitly say what you can use it for, based on the exclusions, I was assuming if the type is FILE_TYPE_DISK, then you can get the size. I (personally) don't know of another other cases where you have a file of type FILE_TYPE_DISK but you can't call GetFileSize. It seems like another type would be more appropriate. |
Appreciate the follow up. That's a good question. I didn't explore what that In that case, this issue seems legit. You put it clearly. However you define the correct behavior, the behavior needs to be one of either: (a) an actually seekable file handle or (b) not one. By being told |
I confirmed that this still occurs in a recent insider build: ver: The good news, however, is that this does work in WSL2. That said, it would be nice to have this fixed in WSL1 as well... |
This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request. Thank you! |
Please see the attached for a reproducible code sample.
Running wslbug.exe < input.txt from Windows yields (the contents of input.txt don't matter, can even be empty):
1
Worked
From WSL:
1
GetFileSizeEx error 1
It appears that calling GetFileSizeEx on a stdin handle redirected from a file from WSL does not work properly. Error 1 means:
ERROR_INVALID_FUNCTION
1 (0x1)
Incorrect function.
Details of my environment:
uname -a: Linux DESKTOP 4.4.0-17763-Microsoft #194-Microsoft Mon Dec 03 17:58:00 PST 2018 x86_64 x86_64 x86_64 GNU/Linux
ver: Microsoft Windows [Version 10.0.17763.195]
wslbug.cpp.txt
The text was updated successfully, but these errors were encountered: