upload-archive: monitor child communication more carefully.
Franck noticed that the code around polling and relaying messages
from the child process was quite bogus. Here is an attempt to
clean it up a bit, based on his patch:
- When POLLHUP is set, it goes ahead and reads the file
descriptor. Worse yet, it does not check the return value of
read() for errors when it does.
- When we processed one POLLIN, we should just go back and see
if any more data is available. We can check if the child is
still there when poll gave control back at us but without any
actual input.
[jc: with simplification suggested by Franck. ]
Signed-off-by: Junio C Hamano <junkio@cox.net>