Blame SOURCES/bz1422573_2-dont-override-user-signals.patch

414eb6
commit c751993c901805cc5cd02622c8672bbc7f8d6849
414eb6
Author: Christine Caulfield <ccaulfie@redhat.com>
414eb6
Date:   Fri Feb 24 16:23:43 2017 +0000
414eb6
414eb6
    loop: don't override external signal handlers
414eb6
    
414eb6
    qb_loop_signal_add() used to set any signals it wasn't managing
414eb6
    back to SIG_DFL. This is unfriendly behaviour in a library.
414eb6
    
414eb6
    Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
414eb6
    Reviewed-by: Jan Pokorný <jpokorny@redhat.com>
414eb6
414eb6
diff --git a/lib/loop_poll.c b/lib/loop_poll.c
414eb6
index 5c75748..386cae6 100644
414eb6
--- a/lib/loop_poll.c
414eb6
+++ b/lib/loop_poll.c
414eb6
@@ -643,8 +643,6 @@ _adjust_sigactions_(struct qb_signal_source *s)
414eb6
 		if (needed) {
414eb6
 			sigaddset(&s->signal_superset, i);
414eb6
 			sigaction(i, &sa, NULL);
414eb6
-		} else {
414eb6
-			(void)signal(i, SIG_DFL);
414eb6
 		}
414eb6
 	}
414eb6
 }
414eb6
@@ -775,6 +773,7 @@ qb_loop_signal_del(qb_loop_t * lp, qb_loop_signal_handle handle)
414eb6
 	}
414eb6
 
414eb6
 	qb_list_del(&sig->item.list);
414eb6
+	signal(sig->signal, SIG_DFL);
414eb6
 	free(sig);
414eb6
 	_adjust_sigactions_(s);
414eb6
 	return 0;
414eb6
diff --git a/tests/check_loop.c b/tests/check_loop.c
414eb6
index ff7f10a..0be5c21 100644
414eb6
--- a/tests/check_loop.c
414eb6
+++ b/tests/check_loop.c
414eb6
@@ -605,6 +605,36 @@ START_TEST(test_loop_sig_handling)
414eb6
 }
414eb6
 END_TEST
414eb6
 
414eb6
+/* Globals for this test only */
414eb6
+static int our_signal_called = 0;
414eb6
+static qb_loop_t *this_l;
414eb6
+static void handle_nonqb_signal(int num)
414eb6
+{
414eb6
+	our_signal_called = 1;
414eb6
+	qb_loop_job_add(this_l, QB_LOOP_LOW, NULL, job_stop);
414eb6
+}
414eb6
+
414eb6
+START_TEST(test_loop_dont_override_other_signals)
414eb6
+{
414eb6
+	qb_loop_signal_handle handle;
414eb6
+
414eb6
+	this_l = qb_loop_create();
414eb6
+	fail_if(this_l == NULL);
414eb6
+
414eb6
+	signal(SIGUSR1, handle_nonqb_signal);
414eb6
+
414eb6
+	qb_loop_signal_add(this_l, QB_LOOP_HIGH, SIGINT,
414eb6
+			   this_l, sig_handler, &handle);
414eb6
+	kill(getpid(), SIGUSR1);
414eb6
+	qb_loop_run(this_l);
414eb6
+
414eb6
+	ck_assert_int_eq(our_signal_called, 1);
414eb6
+
414eb6
+	qb_loop_destroy(this_l);
414eb6
+}
414eb6
+END_TEST
414eb6
+
414eb6
+
414eb6
 START_TEST(test_loop_sig_only_get_one)
414eb6
 {
414eb6
 	int res;
414eb6
@@ -706,6 +736,7 @@ loop_signal_suite(void)
414eb6
 	add_tcase(s, tc, test_loop_sig_handling, 10);
414eb6
 	add_tcase(s, tc, test_loop_sig_only_get_one);
414eb6
 	add_tcase(s, tc, test_loop_sig_delete);
414eb6
+	add_tcase(s, tc, test_loop_dont_override_other_signals);
414eb6
 
414eb6
 	return s;
414eb6
 }