From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4398 invoked by alias); 24 Aug 2013 21:48:57 -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: 31663 Received: (qmail 27016 invoked from network); 24 Aug 2013 21:48:51 -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.175 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=bCeGvt86SSpTHUN28Ksmavsz7FfLUo04eJlSEg1isZM=; b=dbb0wmsKKj5MIiGf0b/dZd1KbtAsgPHjaGnB95u3ITWojtaIqUiQQzgCoTNtOCuyQl SLoZcYtw/27dbetS0CCvDNYmoc8vxF5SGPpH7T1NCtmtaG6N2n631CiWKruTCOhZ2r41 zShVxHiq0/wcPwqyQIqTa1ByCjNJI6YnWxI9XnuEW2n/hwGVCAQWvV2Cq3TsdIi9+H8F Uw0lVVyCmWmDX3jshDV8/BFFvgIA5G/Vfiqnpn8W1qyd0LUUDE53OBld7vOL30uxHkXQ eQy4B/grDAzMjYrfdBO46k1KEmTTrBSnR/XbPsuAxbiIID09sIrKHTr3farj0PIpLR4G VIYQ== X-Gm-Message-State: ALoCoQkVksfSYxuh3solaB54GuzWaqnLfsZ6RUptMhZgPmrhEnz8UEAOSG17M+YOFO/ZLu6jhdCW X-Received: by 10.14.177.199 with SMTP id d47mr11170794eem.14.1377380923199; Sat, 24 Aug 2013 14:48:43 -0700 (PDT) X-ProxyUser-IP: 86.6.30.159 Date: Sat, 24 Aug 2013 22:48:39 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: zpty non-functional? Message-ID: <20130824224839.5830e7fd@pws-pc.ntlworld.com> In-Reply-To: <130824131041.ZM15573@torch.brasslantern.com> References: <20130824124422.GA14766@mugenguild.com> <130824131041.ZM15573@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 13:10:41 -0700 Bart Schaefer wrote: > A quick check with "ps"/"strace" indicates that "cat" is being stopped with > a TTIN signal. That's kind of odd, it means that in spite of being on a > new pty it is not being "attached" to that tty as group leader. I would say > this is in fact a bug in zpty. Hmm... this is well outside my comfort zone. I thought the following existing code: #ifdef TIOCSCTTY ioctl(slave, TIOCSCTTY, 0); #endif should have that effect (man tty_ioctl, all the following on Linux, actually Fedora 15): TIOCSCTTY int arg Make the given terminal the controlling terminal of the calling process. But it apparently doesn't, and sure enough with the patch below... % zpty x cat % zpty -w x this is some text % zpty -r x var % print $var this is some text (I think you need that "var" there, otherwise zpty waits for the process to exit, which isn't what you want. This is not the only place the syntax is a bit wayward...) The following is after the setsid() (or setpgrp() if that fails or doesn't exist). Maybe it should be conditional on one of those succeeding (and do we *really* want to do setpgrp() if setsid() fails, even with a warning)? Or maybe I'm missing the point entirely and just got lucky? diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c index 25ec7df..f31e0ba 100644 --- a/Src/Modules/zpty.c +++ b/Src/Modules/zpty.c @@ -344,6 +344,7 @@ newptycmd(char *nam, char *pname, char **args, int echo, int nblock) if (get_pty(0, &slave)) exit(1); + 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. */ -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/