@@ -71,26 +71,6 @@ def log(data, end='\n'):
7171parser .add_argument ('--crlf' , dest = 'crlf' , action = 'store_true' ,
7272 help = "Write \\ r\\ n instead of \\ n to the input" )
7373
74- import errno
75- def list_fds ():
76- """List process currently open FDs and their target """
77- if sys .platform != 'linux2' :
78- raise NotImplementedError ('Unsupported platform: %s' % sys .platform )
79-
80- ret = {}
81- base = '/proc/self/fd'
82- for num in os .listdir (base ):
83- path = None
84- try :
85- path = os .readlink (os .path .join (base , num ))
86- except OSError as err :
87- # Last FD is always the "listdir" one (which may be closed)
88- if err .errno != errno .ENOENT :
89- raise
90- ret [int (num )] = path
91-
92- return ret
93-
9474class Runner ():
9575 def __init__ (self , args , no_pty = False , line_break = "\n " ):
9676 #print "args: %s" % repr(args)
@@ -104,13 +84,11 @@ def __init__(self, args, no_pty=False, line_break="\n"):
10484 env ['TERM' ] = 'dumb'
10585 env ['INPUTRC' ] = '/dev/null'
10686 env ['PERL_RL' ] = 'false'
107- print ("FDS before: %s" % list_fds ())
10887 if no_pty :
10988 self .p = Popen (args , bufsize = 0 ,
11089 stdin = PIPE , stdout = PIPE , stderr = STDOUT ,
11190 preexec_fn = os .setsid ,
112- env = env , close_fds = True )
113- #env=env)
91+ env = env )
11492 self .stdin = self .p .stdin
11593 self .stdout = self .p .stdout
11694 else :
@@ -125,17 +103,14 @@ def __init__(self, args, no_pty=False, line_break="\n"):
125103 self .p = Popen (args , bufsize = 0 ,
126104 stdin = slave , stdout = slave , stderr = STDOUT ,
127105 preexec_fn = os .setsid ,
128- env = env , close_fds = True )
129- #env=env)
106+ env = env )
130107 # Now close slave so that we will get an exception from
131108 # read when the child exits early
132109 # http://stackoverflow.com/questions/11165521
133110 os .close (slave )
134111 self .stdin = os .fdopen (master , 'r+b' , 0 )
135112 self .stdout = self .stdin
136113
137- print ("FDS after: %s" % list_fds ())
138-
139114 #print "started"
140115 self .buf = ""
141116 self .last_prompt = ""
0 commit comments