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

bytesavailable wrong when piping input #54627

Closed
Seelengrab opened this issue May 30, 2024 · 2 comments
Closed

bytesavailable wrong when piping input #54627

Seelengrab opened this issue May 30, 2024 · 2 comments
Labels
bug Indicates an unexpected problem or unintended behavior io Involving the I/O subsystem: libuv, read, write, etc.

Comments

@Seelengrab
Copy link
Contributor

Seelengrab commented May 30, 2024

MWE:

[sukera@tower ~]$ cat example.jl 
function foo()
    while iszero(bytesavailable(stdin))
        println("no data")
        sleep(0.2)
    end
    write(stdout, readavailable(stdin))
    println()
end
[sukera@tower ~]$ echo "foo" | julia -L example.jl -e 'foo()'
no data
no data
no data
no data
no data
no data
no data
^C

This should just print foo\n on stdout and then exit, since there clearly is data available.

@Seelengrab Seelengrab added bug Indicates an unexpected problem or unintended behavior io Involving the I/O subsystem: libuv, read, write, etc. labels May 30, 2024
@KristofferC
Copy link
Member

Ref #14624 (comment)

@Seelengrab
Copy link
Contributor Author

Seelengrab commented May 30, 2024

Right, I keep forgetting that our async I/O is actually synchronous under the hood and that we only start to buffer once you try to read.......

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior io Involving the I/O subsystem: libuv, read, write, etc.
Projects
None yet
Development

No branches or pull requests

2 participants