by pif · 2y ago · 0 comments
In the first example, he is using two pipes; in the second example, he is using one socket. And he complains that that they don't work the same!?!
The problem is that they saw TCP sockets are two-way and then thought to optimize the TCP connection/state overhead by using it for double-duty without applying appropriate abstractions to transparently use a two-way channel as two one-way channels.
Even being receive, odd transmit. That then led to various higher level protocols using pairs of ports. Once TCP took over, that was relaxed.
The best mitigation is to not close `stdin` when you get EOF on it -- just stop reading from `stdin`.