2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-28 04:48:16 +00:00
criu/test/inhfd/tty.py
Andrei Vagin 212e4c771a test: make zdtm.py python2/python3 compatible
Cc: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-06-08 09:54:22 +03:00

18 lines
423 B
Python
Executable File

import os, pty
import termios, fcntl
def child_prep(fd):
fcntl.ioctl(fd.fileno(), termios.TIOCSCTTY, 1)
def create_fds():
(fd1, fd2) = pty.openpty()
return (os.fdopen(fd2, "wb"), os.fdopen(fd1, "rb"))
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)]