-
Notifications
You must be signed in to change notification settings - Fork 1
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
"Bad file descriptor" error #5
Comments
I've experienced that error on my Mac as well. For me it is intermittent/inconsistent. Some runs, everything works fine. Are you experiencing this error every time you run it? I've also been able to decrease the number of times I get this by moving the code that calls using TERMIOS
const T = TERMIOS
function main()
term_stdin = T.termios()
T.tcgetattr(stdin, term_stdin)
term_stdin.c_iflag |= T.IGNBRK
T.tcsetattr(stdin, T.TCSANOW, term_stdin)
end
main() Or just in a Your code was erroring in the first call to |
Thanks for your time and the fast response! I've just tried your suggestion both as a file and in the repl, and I get the same error.
|
Interesting. Can you try the following in python? import termios, sys
fd = sys.stdin.fileno()
print(fd)
termios.tcgetattr(fd) |
Yes, In [1]: import termios, sys
...: fd = sys.stdin.fileno()
...: print(fd)
...: termios.tcgetattr(fd)
0
Out[1]:
[16640,
5,
191,
35387,
15,
15,
[b'\x03',
b'\x1c',
b'\x7f',
...
b'\x00']] the last element of a list is itself a list with 32 byte elements |
In Python, this is the source: And in julia, this is the source: Lines 601 to 613 in 37d991d
You can see they are pretty much identical. Now, the only thing that could be different is the layout of the Can you print If there's a difference in the layout, then it is something that can be fixed in this package. If there's no difference in the layout, we'll have to ping someone on the core Julia team who has knowledge of libuv and Julia's IO system for more information about what is going on. |
Interestingly the tests on Travis are passing: https://travis-ci.com/github/kdheepak/TERMIOS.jl/jobs/287020194#L153 Lines 56 to 64 in 37d991d
|
Regarding layout, the result of using #include <termios.h>
#include <unistd.h> indicates that on my system we have typedef unsigned char cc_t;
typedef unsigned int speed_t;
typedef unsigned int tcflag_t;
struct termios
{
tcflag_t c_iflag;
tcflag_t c_oflag;
tcflag_t c_cflag;
tcflag_t c_lflag;
cc_t c_line;
cc_t c_cc[32];
speed_t c_ispeed;
speed_t c_ospeed;
}; All looks ABI compatible when compared to |
Is this a problem? julia> TERMIOS._file_handle(stdout)
RawFD(0x61636d20)
julia> stdout
Base.TTY(RawFD(0x0000000d) open, 0 bytes waiting) The |
Ok, I also have a mismatch in my personal computer. julia> using TERMIOS
julia> TERMIOS._file_handle(stdout)
RawFD(0x20657370)
julia> stdout
Base.TTY(RawFD(0x0000000d) open, 0 bytes waiting) In a remote server I also have a mismatch, but with a different output for julia> using TERMIOS
julia> TERMIOS._file_handle(stdout)
RawFD(0x00000000)
julia> stdout
Base.TTY(RawFD(0x0000000d) open, 0 bytes waiting) If I try in the server the code suggested by @kdheepak here, then I don't get the "Bad file descriptor" error. But later when trying examples from TerminalUserInterface.jl I get the complain about |
So this is definitely the issue, right? Line 599 in 37d991d
Any idea what we should use instead? |
Well, there's |
Is kdheepak/TerminalUserInterfaces.jl#3 If so, I can make the |
Surprisingly I'm unable to reproduce this issue on my Ubuntu VM. But I've gone ahead updated to use I just submitted a registration request for a new version (v0.2.1) of this package: 3c32ffd. When that is merged and tagged, if others can try it out that would be great. |
I'm closing this issue. I believe with the fix it should now work. |
Hi, I saw your (great) presentation today and wanted to try TerminalUserInterfaces.jl
but I'm having a "Bad file descriptor" error. posted the issue here since I think my problem starts with TERMIOS.
I don't understand it, sorry if it is obvious.
Working in linux (linux mint 19.3 64 bit).
I copied the usage example from the docs into a file "termios-debug.jl":
The text was updated successfully, but these errors were encountered: