3 ms·
Your comment made me think of a very difficult programming interview question: Can you copy STDIN to STDOUT in a non-blocking fashion? My point: The most trivi
by throwaway2037 5y ago
Your comment made me think of a very difficult programming interview question: Can you copy STDIN to STDOUT in a non-blocking fashion? My point: The most trivial solutions assume that STDIN will give you all the data very quickly, then STDOUT will accept 100% "instantly". Using only Java, I don't know the solution off the top of my head. I will need to do a little bit of research.
However, using POSIX calls with C (select() and friends), yes, I could imagine a way to do it.
Deeper: Can you write a function to launch an external process then (a) write to its STDIN, (b) read from its STDOUT, (c) read from its STDERR -- all independently and without blocking? It's a hard problem!