How to know when stdin is empty if it contains EOF?
问题 In an attempt to create a simple cat clone in python, sys.stdout.write(sys.stdin.read()) I noticed that this fails horribly for binary files (i.e. python cat.py < binaryfile > supposed_copy ) containing the CTRL + Z EOF / substitude character 0x1a, since that seems to cause read() to consider its work done. I cannot simply loop over the code forever to circumvent this, since obviously at some point stdin.read() will wait until new input is provided, which once the true end of input is reached