SIGCHLD handler must be blocked during execution of SIGTERM handler,
and visa versa, because the former changes "children" hash table
iterated by the latter.

Signed-off-by: Dmitry V. Levin <[email protected]>
---
 nbd-server.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/nbd-server.c b/nbd-server.c
index 0868447..80681c7 100644
--- a/nbd-server.c
+++ b/nbd-server.c
@@ -2454,11 +2454,14 @@ void setup_servers(GArray* servers) {
 
        sa.sa_handler = sigchld_handler;
        sigemptyset(&sa.sa_mask);
+       sigaddset(&sa.sa_mask, SIGTERM);
        sa.sa_flags = SA_RESTART;
        if(sigaction(SIGCHLD, &sa, NULL) == -1)
                err("sigaction: %m");
+
        sa.sa_handler = sigterm_handler;
        sigemptyset(&sa.sa_mask);
+       sigaddset(&sa.sa_mask, SIGCHLD);
        sa.sa_flags = SA_RESTART;
        if(sigaction(SIGTERM, &sa, NULL) == -1)
                err("sigaction: %m");
-- 
ldv

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Nbd-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nbd-general

Reply via email to