criu/test/inhfd/tty.py
Andrew Vagin df0be41e05 zdtm: add a new test to check inherited tty-s
v2: set a control terminal
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-12-29 14:48:36 +03:00

17 lines
421 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, "w"), os.fdopen(fd1, "r"))
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)]