Blob Blame History Raw
From a999c2e9c25a46ffeff0c67ad9b9177d640a4b87 Mon Sep 17 00:00:00 2001
From: Matej Habrnal <mhabrnal@redhat.com>
Date: Tue, 8 Mar 2016 16:45:36 +0100
Subject: [PATCH] a-a-install-debuginfo: fix BrokenPipe error

While debug info is downloading and stop button is pressed the BrokenPipe
error appears.

If the stop button is pressed, gui wizard sends SIGTERM to all
processes with the same group ID so abrt-action-install-debuginfo got SIGTERM
as well. It has its own SIGTERM handler which calls clean_up() function and it
takes a while before the tool is terminated.
abrt-action-install-debuginfo tries to write some messages to the closed socket
during the clean_up process and it raises a BrokenPipe exception. We must
ensure that no message will be printed after SIGTERM is recieved.

Related to: #1255259

Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
---
 src/plugins/abrt-action-install-debuginfo.in | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/plugins/abrt-action-install-debuginfo.in b/src/plugins/abrt-action-install-debuginfo.in
index 7818ffd..e4a7dfd 100644
--- a/src/plugins/abrt-action-install-debuginfo.in
+++ b/src/plugins/abrt-action-install-debuginfo.in
@@ -44,7 +44,7 @@ def init_gettext():
     gettext.textdomain(GETTEXT_PROGNAME)
 
 def sigterm_handler(signum, frame):
-    clean_up(TMPDIR)
+    clean_up(TMPDIR, silent=True)
     exit(RETURN_OK)
 
 def sigint_handler(signum, frame):
@@ -241,6 +241,9 @@ if __name__ == "__main__":
         try:
             result = downloader.download(missing, download_exact_files=exact_fls)
         except Exception as ex:
+            if ex.errno == errno.EPIPE:
+                clean_up(TMPDIR, silent=True)
+                exit(RETURN_FAILURE)
             error_msg_and_die("Can't download debuginfos: %s", ex)
 
         if exact_fls:
-- 
2.5.5