mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-23 10:09:57 +00:00
As discussed on the mailing list, current .py files formatting does not conform to the world standard, so we should better reformat it. For this the yapf tool is used. The command I used was yapf -i $(find -name *.py) Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
36 lines
778 B
Python
Executable file
36 lines
778 B
Python
Executable file
# vim: noet ts=8 sw=8 sts=8
|
|
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)
|