additional sanity check on the fd before we print it in the watchdog.

If it was out of range for whatever reason, it would overflow the buffer.
Also move it out to a separate function.
factor out the routine to calculate the fileno of the last logfile
watchdog should be avoiding anything that looks like a logfile fd too