Hello,
I am implementing the unix shell pipe feature in
java.
These are multi processed pipes that are connected with the java pipe streams. Only if the commands expect to use an input stream (like more, grep etc.) then then read from it else commands like ls etc that do not need the i/p stream ignore it and just write to the output stream provided (std out / piped output).
The problem I'm facing now is that if ls output is huge (if the final
string is about 2000+ characters), then while flushing to the piped output stream, my code hangs. This is the case only when ls is being piped to a command that does not read input.
So
ls | more works fine but
ls | alias does not since alias not not read the input stream that ls is writing to.
Is there a limitation to the number of bytes that can be written to the piped output stream that is not being read? Is there an easier solution to this?
If anyone has faced this issue before or knows the right way of handling this, please do let me know.
Appreciate your help.
Harsha