Comment 25 for bug 1094218

Revision history for this message
Kevin Normoyle (knormoyle) wrote : Re: lsb_release crashed with IOError in getstatusoutput(): [Errno 10] No child processes

I put a print in lsb_release.py to see what the dpkg-query command is

then did
ipython
 import lsb_release
 lsb_release.check_modules_installed()

the print says:
dpkg-query -f '${Version} ${Provides}
' -W lsb-core lsb-cxx lsb-graphics lsb-desktop lsb-qt4 lsb-languages lsb-multimedia lsb-printing 2>/dev/null

(yes there's a \n in the string ..see the def check_modules_installed() above)

here's commands.getoutput that's executing the dpkg-query. So somehow the pipe is closing before it's being told to by pipe.close?

def getoutput(cmd):
    """Return output (stdout or stderr) of executing cmd in a shell."""
    return getstatusoutput(cmd)[1]

# Ditto but preserving the exit status.
# Returns a pair (sts, output)
#
def getstatusoutput(cmd):
    """Return (status, output) of executing cmd in a shell."""
    import os
    pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r')
    text = pipe.read()
    sts = pipe.close()
    if sts is None: sts = 0
    if text[-1:] == '\n': text = text[:-1]
    return sts, text