Make tor_check_port_forwarding handle incomplete lines
The code for parsing the output of tor-fw-helper uses fgets() on a non-blocking file descriptor to fetch each line of output. This appears to not handle incomplete lines properly. Rather than buffering data until a complete line is returned, fgets will return an incomplete line and set errno to be EAGAIN. fgets() should be replaced with something which can handle incomplete lines.
Issue was originally raised by nickm in bug legacy/trac#1903 (moved) and there is some further discussion in that ticket.