-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
File.read/1
missing 1st binary of /dev/stdin
which comes from Unix pipe
#13780
Comments
File.read
seems missing 1st binary of "/dev/stdin" when it comes from pipe.File.read
seems missing 1st binary of "/dev/stdin" which comes from pipe.
File.read
seems missing 1st binary of "/dev/stdin" which comes from pipe.File.read
missing 1st binary of "/dev/stdin" which comes from unix pipe
File.read
missing 1st binary of "/dev/stdin" which comes from unix pipeFile.read/1
missing 1st binary of /dev/stdin
which comes from Unix pipe
Mh very interesting. However, I'm fairly sure this is happening in Erlang. You can reproduce the same behaviour with: dbg(:file.read_file(~c"/dev/stdin")) |
Yes, this is an Erlang behaviour. I believe the main reason why it does not work is because Erlang pre-buffers all stdin. For example, if you do |
@whatyouhide @josevalim Thank you. JFY(and future me)I, I wrote an issue as erlang/otp#8725 . And received an answer for this. echo hello | elixir --erl -noinput pipe_test_with_file_read.exs
"hello\n" ref. for |
Elixir and Erlang/OTP versions
Operating system
Linux Mint 20.3
Current behavior
I prepare two exs files folloings
pipe_test_with_io_read.exs
IO.read(:stdio, :eof) |> IO.inspect()
pipe_test_with_file_read.exs
File.read!("/dev/stdin") |> IO.inspect()
The behaviours on bash are followings,
It seems like
File.read
cannot get 1st binary which arrived at/dev/stdin
. I test my guess by followings,(ping
-c
option isStop after sending count ECHO_REQUEST packets.
)Expected behavior
File.read!
can read the anonymous pipe, so it would be nice to behave like following,The text was updated successfully, but these errors were encountered: