From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23989 invoked by alias); 25 Aug 2013 19:00:02 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 31665 Received: (qmail 20453 invoked from network); 25 Aug 2013 18:59:57 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 Received-SPF: neutral (ns1.primenet.com.au: 209.85.215.174 is neither permitted nor denied by SPF record at ntlworld.com) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:date:from:to:subject:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=R3CqfCsZvtObNjgXXozSWex0DcM4OotxRZMAA35oqiU=; b=e78D7x8OedO6/smCX/N91TNVdLz9kEEKWjS3yQ3Iq5pNKb+6i/2DQ7gbtIpjCGSIg1 kukcwxXXp6u/0NrTHAML7Aoxrx4XAkqlAU6qRtvW4kUFDugukAuiempGXk9K7Lfw481K KEjxLAinVokS6EpRaZcjr0X43R9g4nJ8pl619+lOyeRSBzoENIUPn6g4xEaokzpwFJyE DP2dsQELt6E/jYEqTQbNHWkt3lYH654OhQkZq7aJ+CnDRdeeXFMjWxN/aAg8gV2VS5K7 1hXzi0FDcTJKtaoQkpsZVjECsIcnt4KxQXYrgX+UTbNbuS/3y7d2mOHBFvBPHeeSG9Qt 4TBg== X-Gm-Message-State: ALoCoQlqjBm6GGQK7wdC07ajP6FUadFCHUbSlHBEcnR/V83RHButPCiq2Vbd4YeV8i0hYMDuDNJ3 X-Received: by 10.15.67.131 with SMTP id u3mr19034952eex.34.1377457189769; Sun, 25 Aug 2013 11:59:49 -0700 (PDT) X-ProxyUser-IP: 86.6.30.159 Date: Sun, 25 Aug 2013 19:59:46 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: zpty non-functional? Message-ID: <20130825195946.2f9799c6@pws-pc.ntlworld.com> In-Reply-To: <130824170157.ZM15713@torch.brasslantern.com> References: <20130824124422.GA14766@mugenguild.com> <130824131041.ZM15573@torch.brasslantern.com> <20130824224839.5830e7fd@pws-pc.ntlworld.com> <130824170157.ZM15713@torch.brasslantern.com> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.7; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sat, 24 Aug 2013 17:01:57 -0700 Bart Schaefer wrote: > I'm a bit > surprised that calling attachtty() works, because it relies on SHTTY > having been set to the right thing, and I don't see that anything in > zpty.c is making sure that slave and SHTTY refer to the same fd; but > perhaps it always is for some indirect reason ... > > Is it safe/reasonable to add > > SHTTY = slave; > > right before the attachtty() call in your patch? That seems to work, anyway. I added a test, but if instead of using the pipe I add a string as arguments to zpty -w it usually fails: I get some of the string followed by the whole of the string in the output. This suggests the write is doing something weird. I added the trick to make it use _exit() (as we haven't forked) at the end of the slave code, but that didn't help --- which it probably shouldn't anyway for various reasons, but I left it in since it looked logically correct anyway. So there's something else to investigate. diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c index 25ec7df..3821194 100644 --- a/Src/Modules/zpty.c +++ b/Src/Modules/zpty.c @@ -344,6 +344,8 @@ newptycmd(char *nam, char *pname, char **args, int echo, int nblock) if (get_pty(0, &slave)) exit(1); + SHTTY = slave; + attachtty(mypid); #ifdef TIOCGWINSZ /* Set the window size before associating with the terminal * * so that we don't get hit with a SIGWINCH. I'm paranoid. */ @@ -398,6 +400,7 @@ newptycmd(char *nam, char *pname, char **args, int echo, int nblock) opts[INTERACTIVE] = 0; execode(prog, 1, 0, "zpty"); stopmsg = 2; + mypid = 0; /* trick to ensure we _exit() */ zexit(lastval, 0); } master = movefd(master); diff --git a/Test/.distfiles b/Test/.distfiles index 689b695..ab92153 100644 --- a/Test/.distfiles +++ b/Test/.distfiles @@ -40,6 +40,7 @@ V04features.ztst V05styles.ztst V06parameter.ztst V07pcre.ztst +V08zpty.ztst Y01completion.ztst Y02compmatch.ztst Y03arguments.ztst diff --git a/Test/V08zpty.ztst b/Test/V08zpty.ztst new file mode 100644 index 0000000..d9d24c5 --- /dev/null +++ b/Test/V08zpty.ztst @@ -0,0 +1,20 @@ +# zpty is required by tests of interactive modes of the shell itself. +# This tests some extra things. + +%prep + + if ! zmodload zsh/zpty 2>/dev/null + then + ZTST_unimplemented="the zsh/zpty module is not available" + return 0 + fi + +%test + + zpty cat cat + print a line of text | zpty -w cat + var= + zpty -r cat var && print -r -- ${var%%$'\r\n'} + zpty -d cat +0:zpty with a process that does not set up the terminal +>a line of text -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/