Moved fcntl locking code into util.c to allow it to be