Issue 1346211: commands.getstatusoutput() - Python tracker (original) (raw)

Issue1346211

Created on 2005-11-02 18:20 by dawalama, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
commands.py dawalama,2005-11-02 19:50 Commands.py with updated getoutputstatus
Messages (3)
msg48943 - (view) Author: Dawa Lama (dawalama) Date: 2005-11-02 18:20
when you run a script using > commands.getstatusoutput() I was getting sh in the process list. Looks like the problem was because of >pipe.read() Following if the modification to the module commands.py which runs without the defunct'ing the shell. ============================================= def getstatusoutput( cmd ): """Return (status, output) of executing cmd in a shell.""" import os pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r', 0) try: lines = pipe.readline() finally: sts = pipe.close() if sts is None: sts = 0 if lines[-1:] == '\n'; lines = lines[:-1] return sts, lines
msg48944 - (view) Author: Dawa Lama (dawalama) Date: 2005-11-02 18:57
Logged In: YES user_id=517642 def getstatusoutput( cmd ): """Return (status, output) of executing cmd in a shell.""" import os pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r', 0) lines = None try: lines = pipe.readline() finally: sts = pipe.close() if sts is None: sts = 0 if lines[-1:] == '\n'; lines = lines[:-1]
msg48945 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-02-19 13:32
Logged In: YES user_id=1188172 I cannot reproduce this. Note that your patch cannot work anyway (using readline() instead of readlines()). The try-finally doesn't help either.
History
Date User Action Args
2022-04-11 14:56:13 admin set github: 42543
2005-11-02 18:20:15 dawalama create