Use lockf rather than flock when taking the cgilock, for better portability.