2010/1/29 Martin Langhoff <martin.langhoff@xxxxxxxxx>: Hallo, Martin. > The flock binary in modern linuxes (from util-linux-ng) supports > flocking a filehandle that is handled by the shell. Combining this > with per-code-block filehandles / io redirection, it is an incredibly > useful construct to protect a code block with a lock. > > The resulting code looks like this (from man flock on Fedora 11): > > ( > flock -s 200 > # ... commands executed under lock ... > ) 200>/var/lock/mylockfile > > I am now discovering that this works in bash, but not in dash. What about implementation of the race-condition protection or locking using this scheme: * `umask 777` -- lock situation using file to be created * `{ echo “creating file using ‘>’ in a working block” ; do_the_task ; } > lock_file` * paralel / concurrent task: `echo “checking file for access using ‘>’” > lock_file && go || echo 'error: access denied' >&2` * `{ mv lock_file || rm lock_file || …. ; } && chmod 666 lock_file` -- releasing the lock (order matters) -- sed 'sed && sh + olecom = love' << '' -o--=O`C #oo'L O <___=E M -- To unsubscribe from this list: send the line "unsubscribe dash" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html