X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org To: cygwin AT cygwin DOT com From: Eric Blake Subject: flock still buggy Date: Tue, 21 Jul 2009 23:26:16 +0000 (UTC) Lines: 33 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit User-Agent: Loom/3.14 (http://gmane.org/) X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com I finally figured out why autoconf is still failing its flock-related tests, and why perl was reliably failing even though my simple attempts in C were always passing. It turns out that if you do: open flock(LOCK_EX) if (!fork) execlp("sleep","sleep","10",NULL); sleep(10); then ProcessExplorer shows that the Event in the global namespace of flock-dev- ino\20-2-* exists in both parent and child, and with a notification level of false, blocking any outside influence until both the parent and forkee exit. But if you do: open fcntl (fd, F_SETFD, FD_CLOEXEC | fcntl (fd, F_GETFD)) flock(LOCK_EX) if (!fork) execlp("sleep","sleep","10",NULL); sleep(10); then only the parent holds a handle to the Event, but with a notification level of true, allowing any outside party to do whatever they want. I'm still trying to figure out why the close-on-exec cleanup appears to be spuriously triggering the flock Event to unlock. But my understanding is that F_FLOCK locks should survive over exec, so the close-on-exec cleanup should only trigger lock release on F_POSIX locks. -- Eric Blake -- 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