Prevent pid race conditions