Explicitly reopen the debug stream via the API.

Currenly, only daemon.c cares about this function.

Also fix a bug causing a SEGFAULT if pidfile is the empty string.