Problem with readlines function in windows

, ,

hi everyone, readlines function does not finish with Ctrl+d. Tested with julia REPL called from CMD, powershell, Windows Terminal, and from an small program.
No problem with linux.

julia> versioninfo()
Julia Version 1.11.2
Commit 5e9a32e7af (2024-12-01 20:02 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 4 × Intel(R) Core(TM) i5-10400 CPU @ 2.90GHz
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, skylake)
Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores)
Environment:
  JULIA_EDITOR = hx.exe

Small program

println("\nEnter some lines, finish with Ctrl+d")
lines=readlines()
println(lines)

Linking related thread.

I haven’t tried it (on my phone right now), but the termination signal on Windows has traditionally been Ctrl-Z.

This doesn’t work for me (Win11 and Julia Version 1.11.2’s REPL)

In case this is useful to someone more knowledgeable than me:

I tried looking into the stream.jl source code. The difference between Linux and Windows seems to be that wait_readnb(stdin, 1) and entering CTRL+D, sets stdin.status to StatusEOF on Linux, but leaves it at StatusOpen on Windows. I imagine this status change is performed in the ccall in start_reading(stdin) / uv_readcb, but I cannot follow the trail at this point.

Yes, I’ve tried it now, too (PowerShell console, Windows Command Prompt, Cygwin, all running inside Windows-Terminal) Neither Ctrl-D nor Ctrl-Z works for any of them. Running Cygwin in the Cygwin-supplied mintty console doesn’t work either.

Running under WSL (also inside Windows-Terminal) does respond correctly: Ctrl-D terminates readlines() correctly, Ctrl-Z terminates the REPL session.

EDIT: In WSL, Ctrl-Z puts the REPL into the background, as I should have remembered: so the REPL is still running.

Closing stdin by pressing Ctrl+D does doesn’t work on Windows · Issue #36645 · JuliaLang/julia
fwiw, some button mashing in the v1.11.2 REPL via Windows PowerShell:

julia> readlines()
^Q^Q^W^W^E^E^R^R^T^T^Y^Y^U^U            ^O^O^P^P
^A^A^D^D^F^F^G^K^K^L^L
^Z^Z^X^X^B^B^N^N

ERROR: InterruptException:

Skipped V (paste) and left C to the end for the interrupt.

1 Like