telnetd: don't exit if waitpid() returns 0.

Noticed while using telnetd to manually test some telnet fixes: telnetd
would sometimes exit when I'd disconnect because it couldn't find pid 0
on its list of sessions.

I've not seen obscure exits because select() times out, but I've also
changed that `return` to an error_exit() so we'll at least know what's
happened if that ever occurs.

Also use <arpa/telnet.h> rather than manually #define'ing its constants,
use the FLAG() macro throughout, and xsetsockopt(). Don't pointlessly
set errno to 0 at the start of main and then never look at it again.
1 file changed