Window resize in "Expect" interact

:date: 2012-11-29
:tags: expect, script
:category: computing
:author: alf

I have written a code in expect which is making it easier for me to make ssh connections.
After a while I noticed that it is really behaving weird on window resize events,
actually it was trying to display as if there was no change in window size.
Googling lead me that I need to make "Expect" to catch resize events, which is "{trap ..... WINCH} in general,
and in particular I had to put this in the beginning of my except code:

.. code-block:: expect

trap {
 set rows [stty rows]
 set cols [stty columns]
 stty rows $rows columns $cols < $spawn_out(slave,name)
} WINCH