Added check to ensure pidfile can be written to. Fixes #1.