example in flock manpage still not useful.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I can see why the following change has been made but, as it is, it
doesn't work at all

http://git.kernel.org/?p=utils/util-linux/util-linux.git;a=commitdiff;h=c348d9346ae60b78a03d6dcd964e23fb40a625df

(
   flock -n 9
   # ... commands executed under lock ...

) 9>/var/lock/mylockfile\fP

flock -n 9 does nothing here besides testing the lock.

I suggest to revert to flock -s 9...or rather to just flock 9, since a
shared lock doesn't indeed seems very useful either here.

The example can be fixed using {   ;} instead of a subshell and adding
flock -n 9 || exit 1, but I think it doesn't match
the intention of the committer which was to show a way to avoid 2
concurrent executions of a script.

If  you want an example exiting the script, I suggest adding an example like:

exec 9>/var/lock/mylockfile  # open the file descriptor for the
duration of the script
flock -n 9 || exit 1                 # exit if the lock can't be acquire.

Pierre
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux