summaryrefslogtreecommitdiff
path: root/pexpect/tests/sigwinch_report.py
blob: f7090cc2f7fee91acca0ed33e861247a3e345781 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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)[0:2]

def handler(signum, frame):
    print 'SIGWINCH:', getwinsize ()

signal.signal(signal.SIGWINCH, handler)

while 1:
	time.sleep(10)