From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: Unreliable flock
Date: Mon, 04 Apr 2016 15:16:00 -0000 [thread overview]
Message-ID: <20160404151644.GB29337@calimero.vinschen.de> (raw)
In-Reply-To: <175808986.20160403002257@yandex.ru>
[-- Attachment #1: Type: text/plain, Size: 1218 bytes --]
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-04-04 15:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-02 21:35 Andrey Repin
2016-04-04 15:16 ` Corinna Vinschen [this message]
2016-04-04 17:05 ` Andrey Repin
2016-04-04 19:06 ` Corinna Vinschen
2016-04-05 2:20 ` Andrey Repin
2016-04-05 8:33 ` Corinna Vinschen
2016-04-04 19:24 ` Warren Young
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160404151644.GB29337@calimero.vinschen.de \
--to=corinna-cygwin@cygwin.com \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).