[Bug 1504127] Re: lsb_release throws exception if stdout is closed

Dimitri John Ledkov launchpad at surgut.co.uk
Fri Sep 30 12:00:12 UTC 2016


Hello,

there is no need to continuously to reproduce this, as it is a standard
python interpret feature to catch SIGPIPE, raise BrokenPipeError on
interpreter exit, and print a message about it to stderr. It is an error
condition in python's opinion, and it does say so.

In my opinion, this is not even a bug.

Why does an extra message on stderr, causes any problems to you, and why
are you calling/testing for ubuntu versions like that? Can you not
redirect stderr to /dev/null, as recommended in
https://bugs.launchpad.net/ubuntu/+source/lsb/+bug/1504127/comments/3 ?

Note that as per
https://bugs.launchpad.net/ubuntu/+source/lsb/+bug/1504127/comments/3
there is no work ongoing to resolve the reported issue.

Could you please explain which software package invocates commands like
that and what the goal is?

checking /proc/version is not that useful, because it only says which kernel is currently running which may not match userspace (e.g. Debian lxd container on Ubuntu kernel is not Ubuntu, or Ubuntu container on a foreign kernel is). If parsing /etc/os-release was enough, why do you still (pointlessly) invoke a python interpreter to parse lsb_release?
lsb_release is deprecated, and imho /usr/lib/os-release should be preferred. Legacy release might only have /etc/os-release or just /etc/lsb-release.

I would avoid all forks all together:
$ grep -iq Ubuntu /etc/os-release /usr/lib/os-release /etc/lsb-release

Please change your code to detect Ubuntu as per ^ for example. Or otherwise the caller that closes stdout of lsb_release, should also redirect stderr if said caller doesn't want to tolerate it, e.g.:
$ ( cat /etc/os-release /proc/version; lsb_release -is 2>/dev/null) | grep -iq Ubuntu

** Changed in: lsb (Ubuntu)
       Status: Triaged => Invalid

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to lsb in Ubuntu.
https://bugs.launchpad.net/bugs/1504127

Title:
  lsb_release throws exception if stdout is closed

Status in lsb package in Ubuntu:
  Invalid

Bug description:
  == Comment: #0 - Liang Chang Guo <lcguo at us.ibm.com> - 2015-10-06 20:43:30 ==
  For testing if a system is Ubuntu, the following combined command with bash always gets extra BrokenPipeError on Ubuntu (14.04 to 15.10):

  # ( cat /etc/os-release /proc/version; lsb_release -is ) | grep -iq Ubuntu 
  Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
  BrokenPipeError: [Errno 32] Broken pipe

  While the return code is correct:
  # ( cat /etc/os-release /proc/version; lsb_release -is ) | grep -iq Ubuntu && echo It-is-Ubuntu
  Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
  BrokenPipeError: [Errno 32] Broken pipe
  It-is-Ubuntu

  It may work well if with slight changes for the command:
  # ( cat /etc/os-release /proc/version; lsb_release -is ) | grep -i Ubuntu
  NAME="Ubuntu"
  ... ...
  # ( cat /etc/os-release /proc/version; lsb_release -is ) | grep -iq UbuntuW
  # ( cat /etc/os-release /proc/version; sleep 1; echo =; lsb_release -is ) | grep -iq Ubuntu
  # cat /etc/os-release /proc/version | grep -iq Ubuntu
  # (lsb_release -is) | grep -iq Ubuntu

  *** Ubuntu Platform Info ***
  # uname -a
  Linux ubt1510J2 4.2.0-12-generic #14-Ubuntu SMP Mon Sep 28 16:50:34 UTC 2015 ppc64le ppc64le ppc64le GNU/Linux

  # dpkg -l bash grep
  ||/ Name                              Version               Architecture          Description
  +++-=================================-=====================-=====================-=========================
  ii  bash                              4.3-14ubuntu1         ppc64el               GNU Bourne Again SHell
  ii  grep                              2.21-2                ppc64el               GNU grep, egrep and fgrep

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/lsb/+bug/1504127/+subscriptions



More information about the foundations-bugs mailing list