Patch from tilman2: Open PID file with O_EXCL