replace libdaemon code with simple flocking code

libdaemon is a dependency which would be nice to remove.  This code replaces the libdaemon
code with flock.  flock *should* be able to reliably create the PID file without any
race conditions.