[Patches] [ python-Patches-1346211 ] commands.getstatusoutput()
SourceForge.net
noreply at sourceforge.net
Wed Nov 2 19:57:28 CET 2005
Patches item #1346211, was opened at 2005-11-02 18:20
Message generated for change (Comment added) made by dawalama
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1346211&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Modules
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Dawa Lama (dawalama)
Assigned to: Nobody/Anonymous (nobody)
Summary: commands.getstatusoutput()
Initial Comment:
when you run a script using
> commands.getstatusoutput()
I was getting sh <defunct> 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
----------------------------------------------------------------------
>Comment By: Dawa Lama (dawalama)
Date: 2005-11-02 18:57
Message:
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]
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1346211&group_id=5470
More information about the Patches
mailing list