Util-Linux package development
 help / color / mirror / Atom feed
* example in flock manpage still not useful.
@ 2011-08-25 12:26 Pierre Gaston
  2011-08-29  9:18 ` Karel Zak
  0 siblings, 1 reply; 3+ messages in thread
From: Pierre Gaston @ 2011-08-25 12:26 UTC (permalink / raw)
  To: util-linux

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-08-29  9:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-25 12:26 example in flock manpage still not useful Pierre Gaston
2011-08-29  9:18 ` Karel Zak
2011-08-29  9:21   ` Peter Breitenlohner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox