From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10116 invoked from network); 12 Jul 2009 14:51:08 -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 new-brage.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.254.104) by ns1.primenet.com.au with SMTP; 12 Jul 2009 14:51:08 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 72778 invoked from network); 12 Jul 2009 14:43:00 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 12 Jul 2009 14:43:00 -0000 Received: (qmail 19209 invoked by alias); 12 Jul 2009 14:42:47 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 27134 Received: (qmail 19183 invoked from network); 12 Jul 2009 14:42:45 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 12 Jul 2009 14:42:45 -0000 Received: from mtaout02-winn.ispmail.ntl.com (mtaout02-winn.ispmail.ntl.com [81.103.221.48]) by bifrost.dotsrc.org (Postfix) with ESMTP id 36E8380307FA for ; Sun, 12 Jul 2009 16:42:33 +0200 (CEST) Received: from aamtaout03-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout02-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20090712144233.QJIV6611.mtaout02-winn.ispmail.ntl.com@aamtaout03-winn.ispmail.ntl.com> for ; Sun, 12 Jul 2009 15:42:33 +0100 Received: from pws-pc ([81.107.42.185]) by aamtaout03-winn.ispmail.ntl.com (InterMail vG.2.02.00.01 201-2161-120-102-20060912) with ESMTP id <20090712144233.KQAK2093.aamtaout03-winn.ispmail.ntl.com@pws-pc> for ; Sun, 12 Jul 2009 15:42:33 +0100 Date: Sun, 12 Jul 2009 15:42:27 +0100 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: non-interactive set -m Message-ID: <20090712154227.6b4bf5cc@pws-pc> In-Reply-To: <20090711195702.52896b2a@pws-pc> References: <200907080858.n688wXfc030608@news01.csr.com> <200907081349.n68DneSv001850@news01.csr.com> <20090709212345.05cc2213@pws-pc> <20090711195702.52896b2a@pws-pc> X-Mailer: Claws Mail 3.7.1 (GTK+ 2.16.2; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Cloudmark-Analysis: v=1.0 c=1 a=NLZqzBF-AAAA:8 a=jOTAElgOUXYb3pMxPOoA:9 a=wChXoqouMeYcyoTBaGwA:7 a=5aNijjF917vzMYRJ_4TR63m3sCwA:4 a=_dQi-Dcv4p4A:10 X-Virus-Scanned: ClamAV 0.94.2/9555/Sat Jul 11 10:31:19 2009 on bifrost X-Virus-Status: Clean On Sat, 11 Jul 2009 19:57:02 +0100 Peter Stephenson wrote: > Again, this passed a trivial smoke test. From the non-interactive case > I think keeping SHTTY around is benign, but we're heading into > more difficult territory. We should make sure it's closed on an exec, however. This maybe what the previous code was trying to do. Index: Src/exec.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/exec.c,v retrieving revision 1.169 diff -u -r1.169 exec.c --- Src/exec.c 11 Jul 2009 19:06:52 -0000 1.169 +++ Src/exec.c 12 Jul 2009 14:38:36 -0000 @@ -595,6 +595,12 @@ * here, which should be visible to external processes. */ closem(FDT_XTRACE); +#ifndef FD_CLOEXEC + if (SHTTY != -1) { + close(SHTTY); + SHTTY = -1; + } +#endif child_unblock(); if ((int) strlen(arg0) >= PATH_MAX) { zerr("command too long: %s", arg0); Index: Src/init.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/init.c,v retrieving revision 1.105 diff -u -r1.105 init.c --- Src/init.c 11 Jul 2009 16:43:00 -0000 1.105 +++ Src/init.c 12 Jul 2009 14:38:36 -0000 @@ -480,8 +480,16 @@ if (SHTTY == -1) { zsfree(ttystrname); ttystrname = ztrdup(""); - } else if (!ttystrname) { - ttystrname = ztrdup("/dev/tty"); + } else { +#ifdef FD_CLOEXEC + long fdflags = fcntl(SHTTY, F_GETFD, 0); + if (fdflags != (long)-1) { + fdflags |= FD_CLOEXEC; + fcntl(SHTTY, F_SETFD, fdflags); + } +#endif + if (!ttystrname) + ttystrname = ztrdup("/dev/tty"); } /* We will only use zle if shell is interactive, * -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/