This commit is contained in:
edschuy95 2026-01-22 19:51:30 -05:00
parent 020f266ab6
commit d5ac6e68ec

View file

@ -647,12 +647,23 @@ def game_launch(gameargs):
else:
master_fd, slave_fd = pty.openpty()
# Close all file descriptors except the pty
# This prevents inheritance of file manager's stdin/stdout
max_fd = 1024 # Reasonable upper limit
for fd in range(3, max_fd):
try:
os.close(fd)
except OSError:
pass
pty_proc = subprocess.Popen(
[game_exe, "+set", "ttycon", "1"] + gameargs,
stdin=slave_fd,
stdout=slave_fd,
stderr=slave_fd,
close_fds=True
close_fds=True,
# Don't let the child process be affected by parent's terminal
preexec_fn=os.setsid if hasattr(os, 'setsid') else None
)
os.close(slave_fd)