Unreliable flock
Corinna Vinschen
corinna-cygwin@cygwin.com
Mon Apr 4 15:16:00 GMT 2016
On Apr 3 00:22, Andrey Repin wrote:
> Greetings, All!
>
> The script (let's call it test.sh):
>
> #!/bin/dash -x
> _lock="./console-session.lock"
> {
> flock -n 9 || {
> echo "The $(cat "$_lock") command is running already."
> exit 3
> } >&2
>
> printf "$1" >&9
>
> trap 'rm "$_lock";' EXIT HUP INT ABRT TERM
>
> sleep 20
>
> } 9>> "$_lock"
>
> Very simple in essence.
> The one-liner:
>
> { flock -n 9 && sleep 10 || echo Fail;} 9>> ./console-session.lock
>
> Also extremely simple.
>
> Open two terminals. mintty or native, bash or dash, doesn't matter.
> chdir to the directory with the script.
>
> Start script in one terminal. ./test.sh
> Start oneliner in another terminal. Fail. How predictable!
I don't know what I'm doing wrong, but this WJFFM with Cygwin 2.4.1
as well as 2.5.0. Additionally I tried to put the oneliner into a
script but it still WFM.
Apart from that, did you notice the flock restrictions outlined in
https://cygwin.com/cygwin-api/std-notes.html ?
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20160404/20fbf21c/attachment.sig>
More information about the Cygwin
mailing list