I’m trying to read all the output from an external program like this (MWE):
out = Pipe() run(pipeline(`head -c10 /dev/urandom`, stdout=out), wait=true) close(out.in) read(out) |> length # shows "10" as expected
This is a snippet I found here on discourse, and I actually need
pipeline (not just
read(cmd)) because in the real code
stdin arguments are also used.
The code above works fine when the output is relatively short with length less or equal to 65536 bytes. When the command outputs more bytes (increase
-c10 in the MWE), the same code suddenly hangs forever without any CPU usage. This happens at the
I don’t see any mention of such limitations in the docs for
pipeline and cannot find any docs for
Pipe() at all.
How to modify the code so that longer outputs are also read correctly?