[Patches] [ python-Patches-1346211 ] commands.getstatusoutput()

SourceForge.net noreply at sourceforge.net
Wed Nov 2 19:20:15 CET 2005


Patches item #1346211, was opened at 2005-11-02 18:20
Message generated for change (Tracker Item Submitted) made by Item Submitter
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


----------------------------------------------------------------------

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