www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/07/22/11:01:15

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Wed, 22 Jul 2009 17:00:48 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: flock still buggy
Message-ID: <20090722150048.GK27613@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <loom DOT 20090721T231647-613 AT post DOT gmane DOT org> <20090722100804 DOT GF27613 AT calimero DOT vinschen DOT de> <loom DOT 20090722T143408-726 AT post DOT gmane DOT org>
MIME-Version: 1.0
In-Reply-To: <loom.20090722T143408-726@post.gmane.org>
User-Agent: Mutt/1.5.19 (2009-02-20)
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

On Jul 22 14:41, Eric Blake wrote:
> Corinna Vinschen <corinna-cygwin <at> cygwin.com> writes:
> 
> > 
> > Do you have a working C testcase to demonstrate this?
> 
> I still haven't gotten around to trying your patch, but here is the testcase 
> I'm using (I guess it's not that simple, after all):
> [...testcase...]
> For an example of some of the bugs (which I hope your latest patch attempt 
> fixes):
> 
> $ ./foo 4& sleep 2; ./foo 0
> [1] 21692
> ./foo pid 21692 starting
> ./foo pid 21692 got lock
> ./foo pid 21704 forked from 21692
> ./foo pid 21704 unlocked
> ./foo pid 14060 starting
> ./foo pid 14060 got lock
> ./foo pid 21216 forked from 14060
> ./foo pid 21704 exiting
> ./foo pid 21692 exiting
> ./foo pid 21216 exiting
> ./foo pid 14060 exiting
> [1]+  Done                    ./foo 4
> 
> Oops - process 14060 got the lock before 12692 and 21704 exited.

This looks different with my patch:

  $ ./foo 0
  ./foo pid 2712 starting
  ./foo pid 2712 got lock
  ./foo pid 748 forked from 2712
  ./foo pid 748 exiting
  ./foo pid 2712 exiting
  $ ./foo 0
  ./foo pid 2616 starting
  ./foo pid 2616 got lock
  ./foo pid 2892 forked from 2616
  ./foo pid 2892 exiting
  ./foo pid 2616 exiting

> $ ./foo 15
> ./foo pid 10932 starting
> ./foo pid 10932 protected fd
> ./foo pid 10932 got lock
> ./foo pid 10932 closed
> ./foo pid 26264 forked from 10932
> ./foo pid 26264 unlocked
> ./foo pid 26264 execing
> ./foo pid 26264 exiting
> ./foo pid 10932 exiting
> 
> Oops - process 26264 successfully unlocked fd, even though it was marked close-
> on-exec by 10932 before the fork.

Well, sure, it has been marked close-on-exec, but this doesn't mean
the descriptor is invalid after the fork.  AFAICS it's perfectly
valid for the forked child 26264 to unlock the BSD lock.  What am
I missing?


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
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

- Raw text -


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