need to handle BrokenPipeError gracefully

Bug #1207779 reported by Scott Moser
This bug affects 1 person
Affects Status Importance Assigned to Milestone
simplestreams (Ubuntu)
Fix Released

Bug Description

$ ./tools/hook-image-id | head 20130704 apne1pi ami-8326b382 20130704 usee1pe ami-8eadd0e7 20130704 usww1pi ami-848ba2c1 20130704 usww2pi ami-f19407c1 20130704 saee1pi ami-962c898b 20130704 saee1pe ami-bc2c89a1 20130704 apne1pe ami-2d21b42c 20130704 apse1pi ami-34713866 20130704 usee1pi ami-1ab3ce73 20130704 usww2pe ami-f19b08c1
Traceback (most recent call last):
  File "/usr/bin/sstream-sync", line 132, in <module>
  File "/usr/bin/sstream-sync", line 129, in main
    tmirror.sync(smirror.reader, cfg['path'])
  File "/usr/lib/python3/dist-packages/simplestreams/mirrors/", line 58, in sync
    return self.sync_products(reader, path, data, content)
  File "/usr/lib/python3/dist-packages/simplestreams/mirrors/", line 252, in sync_products
    self.insert_item(item, src, target, pgree, ipath_cs)
  File "/usr/lib/python3/dist-packages/simplestreams/mirrors/", line 151, in insert_item
    ret = self.call_hook('insert_item', data=mdata, extra=extra)
  File "/usr/lib/python3/dist-packages/simplestreams/mirrors/", line 196, in call_hook
    capture=capture, rcs=rcs)
  File "/usr/lib/python3/dist-packages/simplestreams/mirrors/", line 211, in call_hook
    return run_command(mcommand, env=env, capture=capture, rcs=rcs)
  File "/usr/lib/python3/dist-packages/simplestreams/mirrors/", line 272, in run_command
    raise subprocess.CalledProcessError(rc, cmd)
subprocess.CalledProcessError: Command '['sh', '-c', './tools/hook-image-id']' returned non-zero exit status 141
Exception BrokenPipeError: BrokenPipeError(32, 'Broken pipe') in <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'> ignored

Example of 'cat'
$ cat /dev/zero | head -c 1 ; echo ${PIPESTATUS[@]}
141 0

ProblemType: Bug
DistroRelease: Ubuntu 13.10
Package: simplestreams 0.1.0~bzr272-0ubuntu1
ProcVersionSignature: Ubuntu 3.10.0-5.15-generic 3.10.2
Uname: Linux 3.10.0-5-generic x86_64
ApportVersion: 2.11-0ubuntu1
Architecture: amd64
Date: Fri Aug 2 10:19:56 2013
EcryptfsInUse: Yes
InstallationDate: Installed on 2011-10-19 (653 days ago)
InstallationMedia: Ubuntu 11.10 "Oneiric Ocelot" - Release amd64 (20111012)
MarkForUpload: True
PackageArchitecture: all
SourcePackage: simplestreams
UpgradeStatus: Upgraded to saucy on 2013-05-20 (74 days ago)

Revision history for this message
Scott Moser (smoser) wrote :
Changed in simplestreams (Ubuntu):
status: New → Confirmed
Changed in simplestreams:
status: New → Confirmed
importance: Undecided → Medium
Changed in simplestreams (Ubuntu):
importance: Undecided → Medium
Revision history for this message
Scott Moser (smoser) wrote :

Originally, I had:
$ cat /etc/passwd | head -n 1
$ echo ${PIPESTATUS[@]}
0 0

Ie, 'cat' exits success.

That is actually not true. that specific example of 'cat' would never get a broken pipe signal as it would read all of /etc/passwd, write all of /etc/passwd , head would read into buf, split lines, exit.

Better example:
$ cat /dev/zero | head -c 1 ; echo ${PIPESTATUS[@]}
141 0

Note that 141-128=13 and SIGPIPE==13

description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package simplestreams - 0.1.0~bzr313-0ubuntu1

simplestreams (0.1.0~bzr313-0ubuntu1) saucy; urgency=low

  * New upstream snapshot.
    * handle sigpipe gracefully (LP: #1207779)
    * as user-friendly cleanup add a trailing '/' to a url if necessary
    * add --delete flag to sstream-sync
    * add python-simplestreams-openstack metapackage so other packages
      could depend on this, but the python-simplestreams package will
      not incur those dependencies. (LP: #1233269)
    * debian/control: Suggest rather than Depend on python-requests.
      Also, up the version to the actual required version (1.1).
 -- Scott Moser <email address hidden> Mon, 30 Sep 2013 15:00:54 -0400

Changed in simplestreams (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.