Fix stdout line_buffering incorrect when parent kitty instance has its stdout redirected to a file

This commit is contained in:
Kovid Goyal 2022-07-13 21:40:55 +05:30
parent 784daa1a4b
commit 9b1c23987c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -828,6 +828,8 @@ def exec_main(stdin_read: int, stdout_write: int, death_notify_write: int, unix_
if unix_socket is None: if unix_socket is None:
unix_socket = random_unix_socket() unix_socket = random_unix_socket()
os.write(stdout_write, f'{get_socket_name(unix_socket)}\n'.encode('utf-8')) os.write(stdout_write, f'{get_socket_name(unix_socket)}\n'.encode('utf-8'))
if not sys.stdout.line_buffering: # happens if the parent kitty instance has stdout not pointing to a terminal
sys.stdout.reconfigure(line_buffering=True) # type: ignore
try: try:
main(stdin_read, stdout_write, death_notify_write, unix_socket) main(stdin_read, stdout_write, death_notify_write, unix_socket)
finally: finally: