fix pid-file race condition