I have a problem using os.pipe() together with os.fork(). Usually when
the writing end of the pipe is closed, the reading end gets EOF. So
subsequent attempts to read data will return an empty string. But when
you call os.fork() after you have created a pipe using os.pipe(), and
read data from the pipe in the child process, when the partent process
has already closed the writing end, the reading end does not get EOF.
Instead of the os.read() call in the child process is blocking.
I am using Linux, so I would like to know if this is a bug in Python or
just weird behaviour under Linux and if it is possible work around it.
print repr(os.read(pipe, 4)) # 'Spam' is printed.
print repr(os.read(pipe, 4)) # Nothing is printed and os.read()
# is blocking, eventhough the other
# end of the pipe was closed.