zsh-workers
 help / color / mirror / code / Atom feed
From: Stefan `Sec` Zehl <sec@42.org>
To: zsh-workers@sunsite.dk
Subject: Can't change stty settings with zle running
Date: Tue, 18 Dec 2007 00:25:08 +0100	[thread overview]
Message-ID: <20071217232508.GA71596@ice.42.org> (raw)

Hi,

I was trying to change a stty setting from within a signal handler:

I used this function

TRAPINFO(){
echo -n pid=$$ tty=`tty` `ttyctl`
zle && echo ", zle running" || echo ", zle NOT running"
stty -a|&grep \ erase
stty gfmt1:erase=7f
stty -a|&grep \ erase
}

When i send a sigINFO from another (important!) shell to this one, I
get the following output:

| ice:~>pid=2414 tty=/dev/ttyp1 tty is not frozen, zle running
|       eol2 = <undef>; erase = ^H; erase2 = ^H; intr = ^C; kill = ^U;
|       eol2 = <undef>; erase = ^?; erase2 = ^H; intr = ^C; kill = ^U;

but if I check the stty settings afterwards, they are reset back:

| ice:~>stty -a|grep \ erase
|       eol2 = <undef>; erase = ^H; erase2 = ^H; intr = ^C; kill = ^U;

Ok. After some experimenting, I now understand, that this happens
because zle is running at that moment.

You can see that zle is the culprit, because if i "kill -INFO $$" from
within the same shell, it works fine:

| ice:~>kill -INFO $$
| pid=2414 tty=/dev/ttyp1 tty is not frozen, zle NOT running
|       eol2 = <undef>; erase = ^H; erase2 = ^H; intr = ^C; kill = ^U;
|       eol2 = <undef>; erase = ^?; erase2 = ^H; intr = ^C; kill = ^U;
| ice:~>stty -a|grep \ erase
|       eol2 = <undef>; erase = ^?; erase2 = ^H; intr = ^C; kill = ^U;

On reading the zshzle manpage, i found "zle -I" which looked very
promising. But unfortunately it doesn't help:

TRAPINFO(){
    zle -I
    echo -n pid=$$ tty=`tty` `ttyctl`
    zle && echo ", zle running" || echo ", zle NOT running"
    stty -a|&grep \ erase
    stty gfmt1:erase=7f
    stty -a|&grep \ erase
    zle -R
}

running "kill -INFO 2414" from another shell again:

| ice:~>
| pid=2414 tty=/dev/ttyp1 tty is not frozen, zle running
|       eol2 = <undef>; erase = ^H; erase2 = ^H; intr = ^C; kill = ^U;
|       eol2 = <undef>; erase = ^?; erase2 = ^H; intr = ^C; kill = ^U;
| ice:~>stty -a|grep \ erase
|       eol2 = <undef>; erase = ^H; erase2 = ^H; intr = ^C; kill = ^U;

results in an improved display, but the stty settings are still
overwritten.

Is it possible to fix zle -I so stty changes will be honored? Or is
there another sane[1] way to do what I want?

Oh, btw. I am running:
| ice:~>echo $ZSH_VERSION
| 4.3.4

Thanks,
    Sec

[1] I managed to work around this problem by defining preexec in my
signal handler and doing the stty change there, and then undefining
preexec again -- This feels very much like "the wrong way".
-- 
Dopeler effect: the tendency of stupid ideas to seem smarter
when they come at you rapidly.


             reply	other threads:[~2007-12-17 23:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-17 23:25 Stefan `Sec` Zehl [this message]
2007-12-18 10:24 ` Peter Stephenson
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=20071217232508.GA71596@ice.42.org \
    --to=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).