From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27048 invoked from network); 18 Dec 2007 10:25:40 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 18 Dec 2007 10:25:40 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 72501 invoked from network); 18 Dec 2007 10:25:32 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 18 Dec 2007 10:25:32 -0000 Received: (qmail 13499 invoked by alias); 18 Dec 2007 10:25:24 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24279 Received: (qmail 13412 invoked from network); 18 Dec 2007 10:25:18 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 18 Dec 2007 10:25:18 -0000 Received: from virusfilter.dotsrc.org (bifrost [127.0.0.1]) by spamfilter.dotsrc.org (Postfix) with ESMTP id 14B378058F54 for ; Tue, 18 Dec 2007 11:22:10 +0100 (CET) Received: from cluster-d.mailcontrol.com (cluster-d.mailcontrol.com [217.69.20.190]) by bifrost.dotsrc.org (Postfix) with ESMTP for ; Tue, 18 Dec 2007 11:22:09 +0100 (CET) Received: from rly13d.srv.mailcontrol.com (localhost.localdomain [127.0.0.1]) by rly13d.srv.mailcontrol.com (MailControl) with ESMTP id lBIAPDDu028504 for ; Tue, 18 Dec 2007 10:25:13 GMT Received: from submission.mailcontrol.com (submission.mailcontrol.com [86.111.216.190]) by rly13d.srv.mailcontrol.com (MailControl) id lBIAOLom025958 for zsh-workers@sunsite.dk; Tue, 18 Dec 2007 10:24:21 GMT Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly13d-eth0.srv.mailcontrol.com (envelope-sender Peter.Stephenson@csr.com) (MIMEDefang) with ESMTP id lBIAOJ3f025883; Tue, 18 Dec 2007 10:24:21 +0000 (GMT) Received: from news01 ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.1830); Tue, 18 Dec 2007 10:24:11 +0000 Date: Tue, 18 Dec 2007 10:24:11 +0000 From: Peter Stephenson To: Stefan `Sec` Zehl , zsh-workers@sunsite.dk Subject: Re: Can't change stty settings with zle running Message-ID: <20071218102411.68d8252b@news01> In-Reply-To: <20071217232508.GA71596@ice.42.org> References: <20071217232508.GA71596@ice.42.org> Organization: CSR X-Mailer: Claws Mail 3.1.0 (GTK+ 2.10.14; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 18 Dec 2007 10:24:11.0451 (UTC) FILETIME=[217C28B0:01C84160] X-Scanned-By: MailControl A-06-00-00 (www.mailcontrol.com) on 10.68.1.123 X-Virus-Scanned: ClamAV using ClamSMTP On Tue, 18 Dec 2007 00:25:08 +0100 Stefan `Sec` Zehl wrote: > I was trying to change a stty setting from within a signal handler: >... > Ok. After some experimenting, I now understand, that this happens > because zle is running at that moment. That's correct. Zle sets its own terminal settings and basically ignores the normal state from then on. > Is it possible to fix zle -I so stty changes will be honored? That seems pretty reasonable since you've explicitly asked to be given control of the terminal. I've added an internal flag for this case; when zle regains control it will save the current settings. I tried it a little, but you probably have a more thorough test. Index: Src/jobs.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/jobs.c,v retrieving revision 1.60 diff -u -r1.60 jobs.c --- Src/jobs.c 5 Sep 2007 16:16:17 -0000 1.60 +++ Src/jobs.c 18 Dec 2007 10:20:28 -0000 @@ -93,7 +93,7 @@ /* 1 if ttyctl -f has been executed */ /**/ -int ttyfrozen; +mod_export int ttyfrozen; /* Previous values of errflag and breaks if the signal handler had to * change them. And a flag saying if it did that. */ Index: Src/Zle/zle_main.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v retrieving revision 1.101 diff -u -r1.101 zle_main.c --- Src/Zle/zle_main.c 13 Dec 2007 21:56:18 -0000 1.101 +++ Src/Zle/zle_main.c 18 Dec 2007 10:20:30 -0000 @@ -208,10 +208,21 @@ zsetterm(void) { struct ttyinfo ti; - #if defined(FIONREAD) int val; +#endif + if (fetchttyinfo) { + /* + * User requested terminal to be returned to normal use, + * so remember the terminal settings if not frozen. + */ + if (!ttyfrozen) + gettyinfo(&shttyinfo); + fetchttyinfo = 0; + } + +#if defined(FIONREAD) ioctl(SHTTY, FIONREAD, (char *)&val); if (val) { /* @@ -1113,6 +1124,7 @@ insmode = unset(OVERSTRIKE); eofsent = 0; resetneeded = 0; + fetchttyinfo = 0; raw_lp = lp; lpromptbuf = promptexpand(lp ? *lp : NULL, 1, NULL, NULL); pmpt_attr = txtchange; Index: Src/Zle/zle_thingy.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_thingy.c,v retrieving revision 1.32 diff -u -r1.32 zle_thingy.c --- Src/Zle/zle_thingy.c 29 May 2007 17:01:09 -0000 1.32 +++ Src/Zle/zle_thingy.c 18 Dec 2007 10:20:30 -0000 @@ -711,6 +711,17 @@ return ret; } + +/* + * Flag that the user has requested the terminal be trashed + * for whatever use. We attempt to keep the tty settings in + * this mode synced with the normal (non-zle) settings unless + * they are frozen. + */ + +/**/ +int fetchttyinfo; + /**/ static int bin_zle_invalidate(UNUSED(char *name), UNUSED(char **args), UNUSED(Options ops), UNUSED(char func)) @@ -721,7 +732,18 @@ * true if a completion widget is active. */ if (zleactive) { + int wastrashed = trashedzle; trashzle(); + if (!wastrashed && (zlereadflags & ZLRF_NOSETTY)) { + /* + * We normally wouldn't have restored the terminal + * in this case, but as it's at user request we do + * so (hence the apparently illogical sense of the + * second part of the test). + */ + settyinfo(&shttyinfo); + } + fetchttyinfo = 1; return 0; } else return 1; -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070