aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2018-03-13 11:58:27 +0000
committerBryn M. Reeves <bmr@redhat.com>2018-03-13 11:59:35 +0000
commitda42466ad3436fff9ea16aab2bfebab9fd586ed8 (patch)
treecceec716725766ad3ce93d8a63e76357e2dbc631
parente6365fa4993411add9662bf5a98f1fb097ed6bab (diff)
downloadsos-da42466ad3436fff9ea16aab2bfebab9fd586ed8.tar.gz
[sosreport] exit status propagation is broken
Fixes: #745 Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/sosreport.py34
1 files changed, 20 insertions, 14 deletions
diff --git a/sos/sosreport.py b/sos/sosreport.py
index 75c5bd66..87e0cc6c 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -808,7 +808,7 @@ class SoSReport(object):
pdb.pm()
def _exit(self, error=0):
- raise SystemExit()
+ raise SystemExit(error)
# sys.exit(error)
def get_exit_handler(self):
@@ -1578,6 +1578,19 @@ class SoSReport(object):
def set_global_plugin_option(self, key, value):
self.global_plugin_options[key] = value
+ def _cleanup(self):
+ try:
+ # archive and tempfile cleanup may fail due to a fatal
+ # OSError exception (ENOSPC, EROFS etc.).
+ if self.archive:
+ self.archive.cleanup()
+ if self.tempfile_util:
+ self.tempfile_util.clean()
+ if self.tmpdir:
+ rmtree(self.tmpdir)
+ except:
+ raise
+
def execute(self):
try:
self.policy.set_commons(self.get_commons())
@@ -1612,20 +1625,13 @@ class SoSReport(object):
return self.final_work()
- except (OSError, SystemExit, KeyboardInterrupt):
- try:
- # archive and tempfile cleanup may fail due to a fatal
- # OSError exception (ENOSPC, EROFS etc.).
- if self.archive:
- self.archive.cleanup()
- if self.tempfile_util:
- self.tempfile_util.clean()
- if self.tmpdir:
- rmtree(self.tmpdir)
- except:
- raise
+ except (OSError):
+ self._cleanup()
+ except (SystemExit, KeyboardInterrupt):
+ self._cleanup()
+ self._exit(0)
- return False
+ self._exit(1)
def main(args):