.
This commit is contained in:
parent
020f266ab6
commit
d5ac6e68ec
1 changed files with 12 additions and 1 deletions
|
|
@ -647,12 +647,23 @@ def game_launch(gameargs):
|
||||||
else:
|
else:
|
||||||
master_fd, slave_fd = pty.openpty()
|
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(
|
pty_proc = subprocess.Popen(
|
||||||
[game_exe, "+set", "ttycon", "1"] + gameargs,
|
[game_exe, "+set", "ttycon", "1"] + gameargs,
|
||||||
stdin=slave_fd,
|
stdin=slave_fd,
|
||||||
stdout=slave_fd,
|
stdout=slave_fd,
|
||||||
stderr=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)
|
os.close(slave_fd)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue