rewrite pid file after forking in daemon mode.

When running in daemon mode, the pid file becomes invalid because the
parent PID is saved.  Instead, ftruncate() and rewrite the file again in
deamon mode after fork()
add INCDIRS/LIBDIRS for FreeBSD