delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=-1.2 required=5.0 tests=AWL,BAYES_00,FB_WORD1_END_DOLLAR,SARE_MSGID_LONG40,SPF_PASS |
X-Spam-Check-By: | sourceware.org |
MIME-Version: | 1.0 |
In-Reply-To: | <20090312155236.GX9322@calimero.vinschen.de> |
References: | <9e3fd2c80903120740u5fa06d62t372cd67212fad1e AT mail DOT gmail DOT com> <20090312155236 DOT GX9322 AT calimero DOT vinschen DOT de> |
Date: | Thu, 12 Mar 2009 17:44:50 +0100 |
Message-ID: | <9e3fd2c80903120944h5aebc094y7e461eee580e4eeb@mail.gmail.com> |
Subject: | Re: Problem getting flock with timeout to work |
From: | Robert Klemme <shortcutter AT googlemail DOT com> |
To: | cygwin AT cygwin DOT com |
X-IsSubscribed: | yes |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT 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 |
--002215046c6ff605d80464eeb302 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi again, 2009/3/12 Corinna Vinschen <corinna-cygwin AT cygwin DOT com>: > On Mar 12 15:40, Robert Klemme wrote: >> Any ideas? =A0Am I doing something wrong? > > On second thought, maybe I don't understand what you're expecting. > Running the testcase on a Linux box I get this: > > Linux calimero 2.6.[etc] > -rw-r--r-- 1 corinna vinschen 0 Mar 12 16:48 lock > timeout 10 > started 1 > 3644 Thu Mar 12 16:48:48 CET 2009 > started 2 > 3644 Thu Mar 12 16:48:49 CET 2009 > waiting... > 3644 Thu Mar 12 16:48:50 CET 2009 > 3644 Thu Mar 12 16:48:51 CET 2009 > 3644 Thu Mar 12 16:48:52 CET 2009 > 3662 Thu Mar 12 16:48:53 CET 2009 > 3662 Thu Mar 12 16:48:54 CET 2009 > 3662 Thu Mar 12 16:48:55 CET 2009 > 3662 Thu Mar 12 16:48:56 CET 2009 > 3662 Thu Mar 12 16:48:57 CET 2009 > done > > 9 seconds > > I don't see that this is different in the sense of "more correct" than > on Cygwin. Well, maybe your Linux is wrong, too. This is what *my* Linux (CentOS 5.2, all packages current) does: [root AT padsw7ora01 tmp]# ~/fl-test-2.sh 1 Linux padsw7 2.6.18-92.1.22.el5 #1 SMP Tue Dec 16 12:03:43 EST 2008 i686 i686 i386 GNU/Linux -rw-r--r-- 1 root root 0 Mar 12 17:39 lock timeout 1 started 1 with PID 17106 17107 1 Thu Mar 12 17:39:29 CET 2009 started 2 with PID 17114 17107 2 Thu Mar 12 17:39:30 CET 2009 waiting... 17107 3 Thu Mar 12 17:39:31 CET 2009 17107 4 Thu Mar 12 17:39:32 CET 2009 17107 5 Thu Mar 12 17:39:33 CET 2009 done [root AT padsw7ora01 tmp]# The second flock does not start the command as I expect it to be. I am referring to the man page of flock which says this about option -w: Fail (with an exit code of 1) if the lock cannot be acquired within seconds seconds. Decimal fractional values are allowed. So, since the second flock obviously cannot obtain the lock in time, I would have expected it to fail and not execute the command given. This is at least a documentation issue as flock's behavior and documentation do not match IMHO. I'll attach another script which implements the other suggested scheme with even more disturbing output: 17:31:09 tmp$ ./fl-test.sh CYGWIN_NT-5.1 padrklemme1 1.5.25(0.156/4/2) 2008-06-12 19:34 i686 Cygwin -rw-r--r-- 1 RKlemme Domain Users 0 Mar 12 17:31 lock timeout 10 started 1 with PID 3160 1 1 Thu Mar 12 17:31:31 WEST 2009 started 2 with PID 1848 2 1 Thu Mar 12 17:31:32 WEST 2009 1 2 Thu Mar 12 17:31:32 WEST 2009 waiting... 2 2 Thu Mar 12 17:31:33 WEST 2009 1 3 Thu Mar 12 17:31:33 WEST 2009 2 3 Thu Mar 12 17:31:34 WEST 2009 1 4 Thu Mar 12 17:31:34 WEST 2009 2 4 Thu Mar 12 17:31:35 WEST 2009 1 5 Thu Mar 12 17:31:35 WEST 2009 2 5 Thu Mar 12 17:31:36 WEST 2009 done 17:31:37 tmp$ Zero locking at all! On my Linux this script behaves as expected: [root AT padsw7ora01 tmp]# ~/fl-test.sh Linux padsw7 2.6.18-92.1.22.el5 #1 SMP Tue Dec 16 12:03:43 EST 2008 i686 i686 i386 GNU/Linux -rw-r--r-- 1 root root 0 Mar 12 17:38 lock timeout 10 started 1 with PID 16989 1 1 Thu Mar 12 17:38:12 CET 2009 started 2 with PID 16994 1 2 Thu Mar 12 17:38:13 CET 2009 waiting... 1 3 Thu Mar 12 17:38:14 CET 2009 1 4 Thu Mar 12 17:38:15 CET 2009 1 5 Thu Mar 12 17:38:16 CET 2009 2 1 Thu Mar 12 17:38:17 CET 2009 2 2 Thu Mar 12 17:38:18 CET 2009 2 3 Thu Mar 12 17:38:19 CET 2009 2 4 Thu Mar 12 17:38:20 CET 2009 2 5 Thu Mar 12 17:38:21 CET 2009 done Now with timeout too short: [root AT padsw7ora01 tmp]# ~/fl-test.sh 1 Linux padsw7 2.6.18-92.1.22.el5 #1 SMP Tue Dec 16 12:03:43 EST 2008 i686 i686 i386 GNU/Linux -rw-r--r-- 1 root root 0 Mar 12 17:38 lock timeout 1 started 1 with PID 17023 1 1 Thu Mar 12 17:38:25 CET 2009 started 2 with PID 17028 1 2 Thu Mar 12 17:38:26 CET 2009 flock error from 2 waiting... 2 1 Thu Mar 12 17:38:27 CET 2009 1 3 Thu Mar 12 17:38:27 CET 2009 2 2 Thu Mar 12 17:38:28 CET 2009 1 4 Thu Mar 12 17:38:28 CET 2009 2 3 Thu Mar 12 17:38:29 CET 2009 1 5 Thu Mar 12 17:38:29 CET 2009 2 4 Thu Mar 12 17:38:30 CET 2009 2 5 Thu Mar 12 17:38:31 CET 2009 done [root AT padsw7ora01 tmp]# Kind regards robert --002215046c6ff605d80464eeb302 Content-Type: application/x-sh; name="fl-test.sh" Content-Disposition: attachment; filename="fl-test.sh" Content-Transfer-Encoding: base64 X-Attachment-Id: f_fs7nuhk90 IyEvYmluL3NoCgp1bmFtZSAtYQoKcm0gLWYgbG9jawp0b3VjaCBsb2NrCmxz IC1sRiBsb2NrCgp0aW1lb3V0PSR7MTotMTB9CmVjaG8gInRpbWVvdXQgJHRp bWVvdXQiCgpmb3IgaSBpbiAxIDIKZG8KICAoCiAgICBmbG9jayAteCAtdyAk dGltZW91dCAyMDAgfHwgZWNobyAiZmxvY2sgZXJyb3IgZnJvbSAkaSIKICAg IGZvciBqIGluIDEgMiAzIDQgNQogICAgZG8KICAgICAgZWNobyAiJGkgJGog YGRhdGVgIgogICAgICBzbGVlcCAxCiAgICBkb25lCiAgKSAyMDA+PmxvY2sg JgogIGVjaG8gInN0YXJ0ZWQgJGkgd2l0aCBQSUQgJCEiCiAgc2xlZXAgMQpk b25lCgplY2hvICJ3YWl0aW5nLi4uIgoKZm9yIGkgaW4gMSAyCmRvCiAgd2Fp dCB8fCBlY2hvICJleGl0IGlzICQ/Igpkb25lCgplY2hvICJkb25lIgo= --002215046c6ff605d80464eeb302 Content-Type: text/plain; charset=us-ascii -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ --002215046c6ff605d80464eeb302--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |