delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2016/04/04/11:17:25

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; q=dns; s=
default; b=GMlFBxGNJYMfEcJGNrEKfzn43W4u2sqaeIgROCGDxpfwa1iScqCgr
X+cMAVcxMI4WoiHWlUU0PMvVvDgKdvOtrsRQQr70lxbKJLXzZoZsAABHpiH+4PNj
F0hFGzWTLsgUAoRx7EQe0W0NOW8KC9G8ku2PV1jGjhfghuPXWvWOIg=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:reply-to
:references:mime-version:content-type:in-reply-to; s=default;
bh=Kek2h5deYhBfr3izw47AilSyrmQ=; b=Xj/JpWIyR5WLfXTXK5+4K+8DGuDV
YDR+xL7tLUyrRa+8HMVExX0OzrLucarP7eQkFbhQDW8BHi4TQngkcZTseLBoeHI5
aOL/JXPQ7cSGRpUIXYEYFzK/UtCyPZgDfjlmpG9G5mCXB2WMC64RQYwB/cm+i6wV
U8gZtOnW1R7a4jM=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-93.9 required=5.0 tests=BAYES_50,GOOD_FROM_CORINNA_CYGWIN,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_PBL,RDNS_DYNAMIC autolearn=ham version=3.3.2 spammy=All, All!, INT, terminals
X-HELO: calimero.vinschen.de
Date: Mon, 4 Apr 2016 17:16:44 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Unreliable flock
Message-ID: <20160404151644.GB29337@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <175808986 DOT 20160403002257 AT yandex DOT ru>
MIME-Version: 1.0
In-Reply-To: <175808986.20160403002257@yandex.ru>
User-Agent: Mutt/1.5.24 (2015-08-30)

--x+6KMIRAuhnl3hBn
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Apr  3 00:22, Andrey Repin wrote:
> Greetings, All!
>=20
> The script (let's call it test.sh):
>=20
> #!/bin/dash -x
> _lock=3D"./console-session.lock"
> {
>   flock -n 9 || {
>       echo "The $(cat "$_lock") command is running already."
>       exit 3
>     } >&2
>=20
>   printf "$1" >&9
>=20
>   trap 'rm "$_lock";' EXIT HUP INT ABRT TERM
>=20
>   sleep 20
>=20
> } 9>> "$_lock"
>=20
> Very simple in essence.
> The one-liner:
>=20
> { flock -n 9 && sleep 10 || echo Fail;} 9>> ./console-session.lock
>=20
> Also extremely simple.
>=20
> Open two terminals. mintty or native, bash or dash, doesn't matter.
> chdir to the directory with the script.
>=20
> 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

--=20
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

--x+6KMIRAuhnl3hBn
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJXAoVcAAoJEPU2Bp2uRE+gMYkP/2Y1z89MPsa/xAAWPPDCi1a4
B1z8Ml0YvfW0BzrjrtrngQpiNI9b+3eazxrEq8sq6i6iqeDsEl33PpiZJpuGLnVX
oM2qiEtkHvlGmrnXOG/OqcXpPFR0sO43GxvFFYI6t94orEvZSFzb+7yKtum3A1aN
R7+4iLLE3J0+3R5gyCpQXqtH9IPk6pdY0wXwLkPoDmurgcRWBRrAzGCtTUflloLA
PeoqsZOf1W1J0wEJ2fsUt52dlZeHDuUWXqgmi8myoePlkb/koIBRU+wpgPc1PuDG
DKrOeOg+d61JVtGCrUU9tSUH50hMA6SG193hTCpZ8w42xE8pfW5e6UbyNK+3LjHA
GQEO+W8W1z6k3r0mxoeLxzE1vZ5r4C4ATsPV2FuyPb1bAd3w0kkgGaw7aZ/Ectkx
GeuPHDxQMn2gwQq6vwfO8oT1q2eBfo2kToVdSt6hOY3IS95wINA4hJfSLjgD/MY1
7cVUwN/VuyZ3Odl+zFFta/zrI1tPTwQmLpqBCl/x24jTqWtTBaOOqdrxZZ3KV5WQ
1tHjAdIoixcPkyWYJCuhiaLtKt4AP7S5YQJyq5oEZMgEqmH9h0lSfQvUR0U9RE8t
5k1XDTXeqHqcyJQj2RQC6GJ9rrtiI2UMnF66iBUE/TUbzV4wyB7PaUzSbPoCpNR2
lOeHbpR3KBHs/nYD+iTP
=79OU
-----END PGP SIGNATURE-----

--x+6KMIRAuhnl3hBn--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019