1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-11 21:57:38 +03:00

Revert accidentally pushed close_fds experiment

This commit is contained in:
Joel Martin 2020-02-11 10:02:53 -06:00
parent 8a19f60386
commit e3615597df

View File

@ -71,26 +71,6 @@ parser.add_argument('mal_cmd', nargs="*",
parser.add_argument('--crlf', dest='crlf', action='store_true',
help="Write \\r\\n instead of \\n to the input")
import errno
def list_fds():
"""List process currently open FDs and their target """
if sys.platform != 'linux2':
raise NotImplementedError('Unsupported platform: %s' % sys.platform)
ret = {}
base = '/proc/self/fd'
for num in os.listdir(base):
path = None
try:
path = os.readlink(os.path.join(base, num))
except OSError as err:
# Last FD is always the "listdir" one (which may be closed)
if err.errno != errno.ENOENT:
raise
ret[int(num)] = path
return ret
class Runner():
def __init__(self, args, no_pty=False, line_break="\n"):
#print "args: %s" % repr(args)
@ -104,13 +84,11 @@ class Runner():
env['TERM'] = 'dumb'
env['INPUTRC'] = '/dev/null'
env['PERL_RL'] = 'false'
print("FDS before: %s" % list_fds())
if no_pty:
self.p = Popen(args, bufsize=0,
stdin=PIPE, stdout=PIPE, stderr=STDOUT,
preexec_fn=os.setsid,
env=env, close_fds=True)
#env=env)
env=env)
self.stdin = self.p.stdin
self.stdout = self.p.stdout
else:
@ -125,8 +103,7 @@ class Runner():
self.p = Popen(args, bufsize=0,
stdin=slave, stdout=slave, stderr=STDOUT,
preexec_fn=os.setsid,
env=env, close_fds=True)
#env=env)
env=env)
# Now close slave so that we will get an exception from
# read when the child exits early
# http://stackoverflow.com/questions/11165521
@ -134,8 +111,6 @@ class Runner():
self.stdin = os.fdopen(master, 'r+b', 0)
self.stdout = self.stdin
print("FDS after: %s" % list_fds())
#print "started"
self.buf = ""
self.last_prompt = ""