File sigterm_in_main_thread.diff of Package device-mapper

Index: LVM2.2.02.45/daemons/clvmd/clvmd.c
===================================================================
--- LVM2.2.02.45.orig/daemons/clvmd/clvmd.c
+++ LVM2.2.02.45/daemons/clvmd/clvmd.c
@@ -374,9 +374,11 @@ int main(int argc, char *argv[])
 	signal(SIGHUP,  sighup_handler);
 	signal(SIGPIPE, SIG_IGN);
 
-	/* Block SIGUSR2 in the main process */
+	/* Block SIGUSR2/SIGINT/SIGTERM in process */
 	sigemptyset(&ss);
 	sigaddset(&ss, SIGUSR2);
+	sigaddset(&ss, SIGINT);
+	sigaddset(&ss, SIGTERM);
 	sigprocmask(SIG_BLOCK, &ss, NULL);
 
 	/* Initialise the LVM thread variables */
@@ -671,6 +673,11 @@ static void main_loop(int local_sock, in
 {
 	DEBUGLOG("Using timeout of %d seconds\n", cmd_timeout);
 
+	sigset_t ss;
+	sigemptyset(&ss);
+	sigaddset(&ss, SIGINT);
+	sigaddset(&ss, SIGTERM);
+	pthread_sigmask(SIG_UNBLOCK, &ss, NULL);
 	/* Main loop */
 	while (!quit) {
 		fd_set in;
@@ -809,6 +816,8 @@ static void main_loop(int local_sock, in
 	}
 
       closedown:
+
+	pthread_sigmask(SIG_BLOCK, &ss, NULL);
 	clops->cluster_closedown();
 	close(local_sock);
 }
openSUSE Build Service is sponsored by