Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Can't change stty settings with zle running



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.



Messages sorted by: Reverse Date, Date, Thread, Author