Lock pidfiles with fcntl and create them atomically.