diff options
author | noah <noah@656d521f-e311-0410-88e0-e7920216d269> | 2003-05-07 23:59:53 +0000 |
---|---|---|
committer | noah <noah@656d521f-e311-0410-88e0-e7920216d269> | 2003-05-07 23:59:53 +0000 |
commit | 2bfd0a230a8e02af456bfc65cac8a76fd1cb44cd (patch) | |
tree | ce31d006a85e5d7823a4363745e4c2a685a8ebe9 | |
parent | 77f7c696ab38ce754ed48a1a666d2b4a9cdf7bb5 (diff) | |
download | pexpect-2bfd0a230a8e02af456bfc65cac8a76fd1cb44cd.tar.gz |
Reports the terminal window size on SIGWINCH signal.
git-svn-id: http://pexpect.svn.sourceforge.net/svnroot/pexpect/trunk@192 656d521f-e311-0410-88e0-e7920216d269
-rw-r--r-- | pexpect/tests/sigwinch_report.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/pexpect/tests/sigwinch_report.py b/pexpect/tests/sigwinch_report.py new file mode 100644 index 0000000..bb2f45b --- /dev/null +++ b/pexpect/tests/sigwinch_report.py @@ -0,0 +1,16 @@ +import time, struct, fcntl, termios, os, sys +import signal, os + +def getwinsize(): + s = struct.pack('HHHH', 0, 0, 0, 0) + x = fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ, s) + return struct.unpack('HHHH', x) + +def handler(signum, frame): + print 'SIGWINCH:', getwinsize () + +signal.signal(signal.SIGWINCH, handler) + +while 1: + time.sleep(10) + |