3 ms·
If I understood correctly, you may be able to do that using pexpect and the interact method. import struct, fcntl, termios, signal, sys def sigwinch_p
by jraph 7y ago
If I understood correctly, you may be able to do that using pexpect and the interact method.
import struct, fcntl, termios, signal, sys
def sigwinch_passthrough (sig, data):
s = struct.pack("HHHH", 0, 0, 0, 0)
a = struct.unpack('hhhh', fcntl.ioctl(sys.stdout.fileno(),
termios.TIOCGWINSZ , s))
if not child.closed:
child.setwinsize(a[0],a[1])
child = pexpect.spawnu("sh", args, encoding='utf-8', logfile=sys.stdout)
signal.signal(signal.SIGWINCH, sigwinch_passthrough)
child.expect_exact("...")
child.logfile = None # Otherwise, interact raises an Exception
child.send("...\n")
child.interact()