teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone

Blame rpm-4.13.0-ignore-sigpipe.patch

Lubos Kardos 363154
From 90d8cc16486479441477e89c2e09bd4f9f7604bb Mon Sep 17 00:00:00 2001
Lubos Kardos 363154
From: Lubos Kardos <lkardos@redhat.com>
Lubos Kardos 363154
Date: Fri, 30 Oct 2015 14:42:32 +0100
Lubos Kardos 363154
Subject: [PATCH] Ignore SIGPIPE signals during execucton of scriptlets
Lubos Kardos 363154
 (rhbz:1264198)
Lubos Kardos 363154
Lubos Kardos 363154
---
Lubos Kardos 363154
 lib/rpmscript.c | 11 +++++++++++
Lubos Kardos 363154
 1 file changed, 11 insertions(+)
Lubos Kardos 363154
Lubos Kardos 363154
diff --git a/lib/rpmscript.c b/lib/rpmscript.c
Lubos Kardos 363154
index 493f4f2..98d3f42 100644
Lubos Kardos 363154
--- a/lib/rpmscript.c
Lubos Kardos 363154
+++ b/lib/rpmscript.c
Lubos Kardos 363154
@@ -271,6 +271,7 @@ static rpmRC runExtScript(rpmPlugins plugins, ARGV_const_t prefixes,
Lubos Kardos 363154
     const char *line;
Lubos Kardos 363154
     char *mline = NULL;
Lubos Kardos 363154
     rpmRC rc = RPMRC_FAIL;
Lubos Kardos 363154
+    struct sigaction newact, oldact;
Lubos Kardos 363154
 
Lubos Kardos 363154
     rpmlog(RPMLOG_DEBUG, "%s: scriptlet start\n", sname);
Lubos Kardos 363154
 
Lubos Kardos 363154
@@ -318,6 +319,12 @@ static rpmRC runExtScript(rpmPlugins plugins, ARGV_const_t prefixes,
Lubos Kardos 363154
 	goto exit;
Lubos Kardos 363154
     }
Lubos Kardos 363154
 
Lubos Kardos 363154
+    /* Ignore SIGPIPE during execution of scriptlets */
Lubos Kardos 363154
+    sigemptyset(&newact.sa_mask);
Lubos Kardos 363154
+    newact.sa_flags = 0;
Lubos Kardos 363154
+    newact.sa_handler = SIG_IGN;
Lubos Kardos 363154
+    sigaction(SIGPIPE, &newact, &oldact);
Lubos Kardos 363154
+
Lubos Kardos 363154
     pid = fork();
Lubos Kardos 363154
     if (pid == (pid_t) -1) {
Lubos Kardos 363154
 	rpmlog(RPMLOG_ERR, _("Couldn't fork %s: %s\n"),
Lubos Kardos 363154
@@ -428,6 +435,10 @@ exit:
Lubos Kardos 363154
 	free(fn);
Lubos Kardos 363154
     }
Lubos Kardos 363154
     free(mline);
Lubos Kardos 363154
+
Lubos Kardos 363154
+    /* Restore SIGPIPE handler */
Lubos Kardos 363154
+    sigaction(SIGPIPE, &oldact, NULL);
Lubos Kardos 363154
+
Lubos Kardos 363154
     return rc;
Lubos Kardos 363154
 }
Lubos Kardos 363154
 
Lubos Kardos 363154
-- 
Lubos Kardos 363154
1.9.3
Lubos Kardos 363154