zsh-workers
 help / color / mirror / code / Atom feed
* Can't change stty settings with zle running
@ 2007-12-17 23:25 Stefan `Sec` Zehl
  2007-12-18 10:24 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan `Sec` Zehl @ 2007-12-17 23:25 UTC (permalink / raw)
  To: zsh-workers

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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-02-11 22:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-17 23:25 Can't change stty settings with zle running Stefan `Sec` Zehl
2007-12-18 10:24 ` Peter Stephenson
2008-02-11 22:41   ` Stefan `Sec` Zehl

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).