Hi again, 2009/3/12 Corinna Vinschen <corinna-cyg...@cygwin.com>: > On Mar 12 15:40, Robert Klemme wrote:
>> Any ideas? Am 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: [r...@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 [r...@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: [r...@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: [r...@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 [r...@padsw7ora01 tmp]# Kind regards robert
fl-test.sh
Description: Bourne shell script
-- 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/