From: Peter Stephenson <pws@csr.com>
To: Stefan `Sec` Zehl <sec@42.org>, zsh-workers@sunsite.dk
Subject: Re: Can't change stty settings with zle running
Date: Tue, 18 Dec 2007 10:24:11 +0000 [thread overview]
Message-ID: <20071218102411.68d8252b@news01> (raw)
In-Reply-To: <20071217232508.GA71596@ice.42.org>
On Tue, 18 Dec 2007 00:25:08 +0100
Stefan `Sec` Zehl <sec@42.org> 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 <pws@csr.com> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
next prev parent reply other threads:[~2007-12-18 10:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-17 23:25 Stefan `Sec` Zehl
2007-12-18 10:24 ` Peter Stephenson [this message]
2008-02-11 22:41 ` Stefan `Sec` Zehl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071218102411.68d8252b@news01 \
--to=pws@csr.com \
--cc=sec@42.org \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).