From: Jacek Konieczny Subject: Re: [PATCH] Fix locking in tools/hotplug/Linux/locking.sh Date: Mon, 12 Nov 2012 19:05:20 +0100 Message-ID: <20121112180519.GA2114@lolek.nigdzie> References: <1352469371-15457-1-git-send-email-jajcus@jajcus.net> <1352738557.27833.302.camel@zakaz.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1352738557.27833.302.camel@zakaz.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: Olaf Hering , "xen-devel@lists.xensource.com" , Ian Jackson List-Id: xen-devel@lists.xenproject.org On Mon, Nov 12, 2012 at 04:42:37PM +0000, Ian Campbell wrote: > On Fri, 2012-11-09 at 13:56 +0000, Jacek Konieczny wrote: > > The claim_lock() function would fail in the perl code with: > > > > Invalid argument at -e line 2. > > > > because the Perl snippet opens for reading the file descriptor, which > > was earlier opened for write (append). > > Looks plausible to me. > > How does this interact with the > eval "exec $_lockfd<&-" > which Olaf added in 26079:b3b03536789a ? I suppose close is close and > <&- and >&- or even <>&- are equivalent? It seems <&- and >&- are indeed the same and there is no such thing as '<>&-'. I have added the Olaf's change to my test setup and it works properly. So no conflict here. > > > > Signed-off-by: Jacek Konieczny > > --- > > tools/hotplug/Linux/locking.sh | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/tools/hotplug/Linux/locking.sh b/tools/hotplug/Linux/locking.sh > > index e34f155..122bcfb 100644 > > --- a/tools/hotplug/Linux/locking.sh > > +++ b/tools/hotplug/Linux/locking.sh > > @@ -44,7 +44,7 @@ claim_lock() > > # See below for a correctness proof. > > local rightfile > > while true; do > > - eval "exec $_lockfd>>$_lockfile" > > + eval "exec $_lockfd<>$_lockfile" > > flock -x $_lockfd || return $? > > # We can't just stat /dev/stdin or /proc/self/fd/$_lockfd or > > # use bash's test -ef because those all go through what is