Explicitly close all fds other than the three std ones before execing()

This commit is contained in:
Kovid Goyal 2016-11-03 19:49:48 +05:30
parent 0f4db0e91e
commit c0e078a3fa

View file

@ -62,6 +62,7 @@ def fork_child(argv, cwd, opts):
for i in range(3):
os.dup2(slave, i)
os.close(slave), os.close(master)
os.closerange(3, 200)
# Establish the controlling terminal (see man 7 credentials)
os.close(os.open(os.ttyname(1), os.O_RDWR))
os.environ['TERM'] = opts.term