2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-22 09:58:09 +00:00
criu/test/inhfd/tty.py
Pavel Tikhomirov b023f0ab5a vim: remove wrong 8-space tabs indent from python files
Probably all vim users can setup their desired indent in their vimrc by
themselfs.

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
2021-09-03 10:31:00 -07:00

36 lines
750 B
Python
Executable File

import fcntl
import os
import pty
import termios
ctl = False
def child_prep(fd):
global ctl
if ctl:
return
ctl = True
fcntl.ioctl(fd.fileno(), termios.TIOCSCTTY, 1)
def create_fds():
ttys = []
for i in range(10):
(fd1, fd2) = pty.openpty()
newattr = termios.tcgetattr(fd1)
newattr[3] &= ~termios.ICANON & ~termios.ECHO
termios.tcsetattr(fd1, termios.TCSADRAIN, newattr)
ttys.append((os.fdopen(fd1, "wb"), os.fdopen(fd2, "rb")))
return ttys
def filename(pipef):
st = os.fstat(pipef.fileno())
return 'tty[%x:%x]' % (st.st_rdev, st.st_dev)
def dump_opts(sockf):
st = os.fstat(sockf.fileno())
return "--external", 'tty[%x:%x]' % (st.st_rdev, st.st_dev)