Redirect SIGHUP, SIGUSR1 and SIGUSR2 to the child if we have one

Oh and send a SIGTERM before our child before we exit ourselves.

Signed-off-by: Toon Schoenmakers <nighteyes1993@gmail.com>
Close our stdin, stdout and stderr before we exit if we're forking into a daemon

Signed-off-by: Toon Schoenmakers <nighteyes1993@gmail.com>
Fix a small bug where pid was not always correctly written to the pidfile

Signed-off-by: Toon Schoenmakers <nighteyes1993@gmail.com>