From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 109320 invoked by alias); 2 Apr 2016 21:35:35 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 109307 invoked by uid 89); 2 Apr 2016 21:35:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=4.0 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,KAM_THEBAT,SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=H*UA:Bat!, H*x:Bat!, H*r:sk:postmas, H*r:4.80.1 X-HELO: smtp.ht-systems.ru Received: from smtp.ht-systems.ru (HELO smtp.ht-systems.ru) (78.110.50.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sat, 02 Apr 2016 21:35:16 +0000 Received: from [95.165.144.62] (helo=darkdragon.lan) by smtp.ht-systems.ru with esmtpa (Exim 4.80.1) (envelope-from ) (Authenticated sender: postmaster@rootdir.org) id 1amTCJ-0007mL-PN for cygwin@cygwin.com; Sun, 03 Apr 2016 00:35:11 +0300 Received: from [192.168.1.10] (HELO daemon2.darkdragon.lan) by daemon2 (Office Mail Server 0.8.12 build 08053101) with SMTP; Sat, 02 Apr 2016 21:22:57 -0000 Date: Sat, 02 Apr 2016 21:35:00 -0000 From: Andrey Repin Reply-To: cygwin@cygwin.com Message-ID: <175808986.20160403002257@yandex.ru> To: All Subject: Unreliable flock MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2016-04/txt/msg00025.txt.bz2 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! Wait till both expire. Now start oneliner first. Then script. Both succeed. Not 100% but highly, highly probable. Sometimes it even work both ways. At the same time, I can't reproduce it on Linux at all. But I do can reproduce it on Cygwin. Both 32 and 64 bit. With both dash and bash. With both local and remote FS. CYGWIN_NT-5.1 foserver 2.4.1(0.293/5/3) 2016-01-24 11:24 i686 Cygwin CYGWIN_NT-6.1 daemon2 2.4.1(0.293/5/3) 2016-01-24 11:26 x86_64 Cygwin CYGWIN_NT-6.1 buildbotw7 2.4.1(0.293/5/3) 2016-01-24 11:26 x86_64 Cygwin -- With best regards, Andrey Repin Saturday, April 2, 2016 23:22:25 Sorry for my terrible english... -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple