Get stdio forwarding working in the PTY tests

This commit is contained in:
Kovid Goyal 2023-08-05 10:47:29 +05:30
parent 88beb58838
commit bc4d7f4cb1
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -214,8 +214,16 @@ class PTY:
from kitty.child import openpty
self.master_fd, self.slave_fd = openpty()
else:
forwarded_fd = STDOUT_FILENO + 2
os.dup2(sys.stdout.fileno(), forwarded_fd)
os.dup2(sys.stderr.fileno(), forwarded_fd+1)
self.child_pid, self.master_fd = fork()
self.is_child = self.child_pid == CHILD
if self.is_child:
os.environ['KITTY_STDIO_FORWARDED'] = str(forwarded_fd)
else:
os.close(forwarded_fd)
os.close(forwarded_fd + 1)
self.child_waited_for = False
if self.is_child:
while read_screen_size().width != columns * cell_width: