Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Apr 2012 17:58:15 +0200
From:      Mel Flynn <rflynn@acsalaska.net>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        Ian Lepore <freebsd@damnhippie.dyndns.org>, FreeBSD Hackers <freebsd-hackers@freebsd.org>
Subject:   Re: Debugging zombies: pthread_sigmask and sigwait
Message-ID:  <4F85AA17.9010107@acsalaska.net>
In-Reply-To: <20120411144703.GM2358@deviant.kiev.zoral.com.ua>
References:  <4F859112.5070005@acsalaska.net> <1334154373.1082.110.camel@revolution.hippie.lan> <20120411144703.GM2358@deviant.kiev.zoral.com.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
On 4/11/2012 16:47, Konstantin Belousov wrote:

> What happens, as I guess it, the SIGINFO and SIGCHLD are ignored, so
> kernel do not even bother to queue the signals to the master process.
> Register a dummy signal handler for your signals with sigaction
> before creating 'signal_handler' thread.

Right on the mark. I've modified the test code accordingly and things
work as expected. I've also applied the logic to the Zarafa spooler and
in the logs I'm finally seeing:
child: [79572] E-mail for user mel was accepted by SMTP server
parent: [79565] Received signal 20
                ^^^^^^^^^^^^^^^^^^

Many thanks and for the archives, the diff below sig.
-- 
Mel

diff -r 509d7301c720 spoolerbug/spoolerbug.c
--- a/spoolerbug/spoolerbug.c   Wed Apr 11 05:37:50 2012 -0800
+++ b/spoolerbug/spoolerbug.c   Wed Apr 11 07:35:50 2012 -0800
@@ -12,6 +12,7 @@
 #include <unistd.h> /* vfork */

 #include <stdlib.h> /* arc4random() */
+#include <string.h> /* memset() */
 #include <stdbool.h>
 #include <getopt.h>

@@ -25,6 +26,7 @@
 void *signal_handler(void *);
 int running_server(void);
 void process_signal(int);
+void signal_dummy(int);

 /* globals */
 pthread_t              signal_thread;
@@ -112,6 +114,12 @@
        }
 }

+void
+signal_dummy(int sig __unused)
+{
+       return;
+}
+
 int
 main(int argc, char *argv[])
 {
@@ -131,11 +139,19 @@

        if( !bForked )
        {
+               struct sigaction dummies;
+
+               memset(&dummies, 0, sizeof(dummies));
                sigemptyset(&signal_mask);
                sigaddset(&signal_mask, SIGTERM);
                sigaddset(&signal_mask, SIGINT);
                sigaddset(&signal_mask, SIGCHLD);
                sigaddset(&signal_mask, SIGINFO);
+               dummies.sa_handler = signal_dummy;
+               dummies.sa_mask = signal_mask;
+               dummies.sa_flags |= SA_NOCLDSTOP;
+               sigaction(SIGCHLD, &dummies, NULL);
+               sigaction(SIGINFO, &dummies, NULL);
        }

        daemon(1, 1);




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4F85AA17.9010107>