From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10016 invoked from network); 22 Mar 2009 23:05:28 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 22 Mar 2009 23:05:28 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 95312 invoked from network); 22 Mar 2009 23:05:22 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 22 Mar 2009 23:05:22 -0000 Received: (qmail 19313 invoked by alias); 22 Mar 2009 23:05:16 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 26766 Received: (qmail 19300 invoked from network); 22 Mar 2009 23:05:15 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 22 Mar 2009 23:05:15 -0000 Received: from mail-ew0-f172.google.com (mail-ew0-f172.google.com [209.85.219.172]) by bifrost.dotsrc.org (Postfix) with ESMTP id 8BFC780590EB for ; Mon, 23 Mar 2009 00:05:10 +0100 (CET) Received: by ewy20 with SMTP id 20so754992ewy.45 for ; Sun, 22 Mar 2009 16:05:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=LVFC9hibdXIL7psy1m187kmH8Ovjy/I0qfk/Zqp3Ct8=; b=W2O4wFTTBykV7hAEtHfPJON1IXoKSNaC7ig/ePpIv+t8SaCB3gN4SDzSdGysHh0HYk tQV9nRI5lGEPIkc5us3uH8F2FyvEylSzrDq0jq8Sh4t5LNwrXDndgG8nywR82S94qVQt I4bFZ7nozhKvQX4CDMivYhBcFu4j99Won8ZEU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=qskMDqkn8KZA9BibukOR1LiGPTNJJ3bSyqBE1XnXbU1RGeFczDKIDg0GyY1JwhHaBD AIcG/41TLtd7ZrwlwpEPI+m+RHux2nCBLHVmaOuVWhdy929TkRokXyZlIxY47Tp17V7/ 45JA4cMRpg1T3SAAhPeRtKag5U7ffV10xqtKA= MIME-Version: 1.0 Received: by 10.210.42.20 with SMTP id p20mr4916848ebp.66.1237763110501; Sun, 22 Mar 2009 16:05:10 -0700 (PDT) In-Reply-To: <20090322125410.66a9d294@pws-pc> References: <237967ef0903201412h2a7b99c9ya5101509a3972313@mail.gmail.com> <20090320224856.73dae001@pws-pc> <237967ef0903201615x72769fe4va86273c3fa07cb2e@mail.gmail.com> <20090322125410.66a9d294@pws-pc> Date: Mon, 23 Mar 2009 00:05:10 +0100 Message-ID: <237967ef0903221605h11983bb4v4eda8d2a1c41a1c9@mail.gmail.com> Subject: Re: cd -s symlink hangs (sometimes?) From: Mikael Magnusson To: zsh-workers Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.92.1/9149/Sun Mar 22 06:12:21 2009 on bifrost X-Virus-Status: Clean 2009/3/22 Peter Stephenson : > On Sat, 21 Mar 2009 00:15:24 +0100 > Mikael Magnusson wrote: >> For some more fun I tried this, and it does still break: >> mkdir a >> ln -s a b >> cd a >> chmod -x . >> cd -s $PWD:h/b >> #infinite loop here still > > This is basically the same problem. I'm not sure why when the directory > is restored wrongly and you end up in "/" you are seeing this infinite > loop and I'm not, but it may just be a side effect. > > The problem is still the code I was scratching my head over before: > > #ifdef HAVE_FCHDIR > if (d->dirfd < 0 && (d->dirfd = open(".", O_RDONLY | O_NOCTTY)) < 0 && > zgetdir(d) && *d->dirname != '/') > d->dirfd = open("..", O_RDONLY | O_NOCTTY); > #endif > > It's now being executed, but we can't open "." any more. So it's > failing to save a fchdir-able directory for restoring, so after the "cd > -s" fails we end up still in / again. > > I'm not sure if there's a full fix for this. It can probably be handled > better than it is at the moment, but apart from warning the user and > making sure the shell knows what directory it's actually in I'm > don't really know how. I just noticed (ls -l /proc/$$/fd) that with this last commit, zsh now keeps all my old directories open, even when I don't use -s or anything special. zsh -f % cd /var % cd log % cd /var/tmp % cd / % cd tmp % ls -g /proc/$$/fd total 0 [...] lr-x------ 1 users 64 2009-03-23 00:03 4 -> /tmp #this is from cwd in the first cd, #not the final cd tmp lr-x------ 1 users 64 2009-03-23 00:03 5 -> /var lr-x------ 1 users 64 2009-03-23 00:03 6 -> /var/log lr-x------ 1 users 64 2009-03-23 00:03 7 -> /var/tmp lr-x------ 1 users 64 2009-03-23 00:03 8 -> / -- Mikael Magnusson