#1745: Adds check to only write pidfile on succuess exec