Flock requires a number rather than a file path for some reason. The other alternative is:

(
    flock -n 9 || exit 1
    # ... commands executed under lock ...
) 9>/var/lock/mylockfile

Is this better? Or should I leave as is?