fix daemonization stdio stuff

With the "close all fds" code commented out, the code was
just opening 3 random descriptors on /dev/null and leaving
normal stdin/out/err attached to the terminal.  The "close
all fds" pattern is bad anyways, so I replaced all that
with dup2 into the standard descriptors properly.

This was causing some odd fallout aside from the obvious
terminal-attachment issues, like the pipe file descriptors
(which I believe are for the DNS threads?) ending up on
fds 1/2 in some cases.

Change-Id: I2c608fc493f0bc5219700c0423e0d55940965823