Skip to content
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

Can't open file descriptors in /proc/[###]/fd #266

Closed
aseering opened this issue Apr 25, 2016 · 18 comments
Closed

Can't open file descriptors in /proc/[###]/fd #266

aseering opened this issue Apr 25, 2016 · 18 comments
Labels

Comments

@aseering
Copy link
Contributor

I'm trying to get bash's process substitution working. It's a few steps shy of working, but, one big one:

The file descriptors under /proc/self/fd aren't openable. They are listed as writeable, but the "open()" libc call is returning -1 when I try to open them.

@aseering
Copy link
Contributor Author

This was discussed in passing by #91

@aseering
Copy link
Contributor Author

Here's a gist of a .c file which, if loaded into a Linux (or Windows-Bash) binary, roughly emulates the desired behavior of these file descriptors. It's good enough to get bash process substitution working, anyway.

It's trying to make /dev/fd work, which is what bash process substition uses and which doesn't exist at all in Windows-Bash. If you want /proc/self/fd, modify line 38 accordingly.

@benhillis
Copy link
Member

benhillis commented Apr 25, 2016

Looks like we're missing the below symlinks in the /dev directory. I just filed an internal bug and will get these added to our dev branch today.

lrwxrwxrwx   1 root root          13 Apr 29  2016 fd -> /proc/self/fd/
lrwxrwxrwx   1 root root          15 Apr 29  2016 stderr -> /proc/self/fd/2
lrwxrwxrwx   1 root root          15 Apr 29  2016 stdin -> /proc/self/fd/0
lrwxrwxrwx   1 root root          15 Apr 29  2016 stdout -> /proc/self/fd/1

Thanks for reporting this!

@aseering
Copy link
Contributor Author

Thanks for the reply, and the quick action! Those symlinks will be very helpful.

Once you have the symlinks, is there any chance you could run the following one-line bash command real quick, as a test case?:

cat <(echo 'hello world') > >(tee tmp.txt)

It should print "hello world" to the terminal, and write a file "tmp.txt" that contains the same string. Works fine on Ubuntu Linux. Doesn't work on my Windows Bash system, even if I modify bash to use /proc/self/fd rather than /dev/fd (which is in effect what adding those symlinks does).

My workaround (above; link to gist) fixes the issue by aliasing open("/proc/self/fd/NNN") to dup(NNN).

If this is already fixed on your end, great! I await the next build :-) If not, just making sure you know what I'm seeing.

@benhillis
Copy link
Member

Something interesting is going on here that I'll need to debug further. I'm getting an error about cat: /dev/fd/63: No such file or directory even though I've verified that the /dev/fd symlink is working correctly. It could be a problem with the tee system call or something else, I'll continue looking into this.

@benhillis benhillis added the bug label Apr 26, 2016
@aseering
Copy link
Contributor Author

Thanks for looking at this! I'll be curious to hear what you find.

@benhillis
Copy link
Member

@aseering - Dug into this a bit more and we're not correctly handling opening pipes by the procfs symlinks correctly (for example open("/dev/fd/1") or open("/proc/self/fd/1"). I've filed a bug internally to track this and we have a good idea of how to fix it.

@benhillis
Copy link
Member

benhillis commented May 16, 2016

This was fixed in our development branch recently and the fix will be making its way to the Windows Insider fast ring.

@aseering
Copy link
Contributor Author

Thanks!

@pefoley2
Copy link

Appears to still be an issue in build 14352.
Hopefully this fix will land in the next release.

@AbhimanyuAryan
Copy link

who says this has been fixed @benhillis I am trying to install rvm and I still have this issue on 14352

cat: /dev/fd/63: No such file or directory
cat: /dev/fd/63: No such file or directory
The downloaded package for https://rubies.travis-ci.org/ubuntu/14.04/x86_64/ruby-2.3.1.tar.bz2,
Does not contains single 'bin/ruby' or 'ruby-2.3.1',
Only '' were found instead.

@mcornella
Copy link

@AbhimanyuAryan he didn't say it was fixed on 14352, but on their internal dev branch. It's probably not yet released.

@AbhimanyuAryan
Copy link

@mcornella my bad so when are we expecting the update? I have un-installed Linux to get Windows and it's still not here. Microsoft said it quite clearly "Ubuntu on Windows" 😥😕

@benhillis
Copy link
Member

@AbhimanyuAryan - Sorry for the confusion, the fix will be an insider release soon. We don't have any control over when Insider builds are released so I apologize that I can't give a more firm timeline.

@AbhimanyuAryan
Copy link

@benhillis you should explain that to Microsoft Insider team that it's "WindowsOnBash" because of which people are making switch not Windows. So they can set the priorities right😞

Btw you guys are doing great work :)

@stehufntdev
Copy link
Collaborator

Insider build 14361 that was just released has the fix for this, and I doubled checked the one line repro above.

@ghost
Copy link

ghost commented Nov 20, 2020

Old and closed issue, I know... But we are experiencing the same issue over at https://github.com/ish-app/ish.
@benhillis Is there any possibilities that you could share some details on how this was solved with us?
Thanks in advance!

@ezzuldinSt
Copy link

ezzuldinSt commented Jan 6, 2021

@benhillis could share some details on how did you solve this?
I’m having the same bug on https://github.com/ish-app/ish
Which is :

sysopen:41: can't open file /proc/self/fd/14: no such file or directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants