RE: [Exim] Frozen deferred messages

Startseite
Nachricht löschen
Nachricht beantworten
Autor: A. Wik
Datum:  
To: Philip Hazel
CC: Mike Bethune, exim-users
Betreff: RE: [Exim] Frozen deferred messages
On Fri, 16 Apr 2004, Philip Hazel wrote:

> On Thu, 15 Apr 2004, Mike Bethune wrote:
>
> > actually, I think I set it in the wrong place before, I've tried the
> > below and it seems to be working for me now... (cross fingers)
>
> That really does suggest that the signal handler gets lost on fork().
> Your patch is certainly harmless, so if it fixes things for you, it is
> the right solution. Noted.


I made a small test program to see if I could confirm the
hypothesis that signal handlers get lost on fork(), but
I could not. It also doesn't seem to be necessary to restore
the handler after it's been used.

Perhaps this code in daemon.c has something to do with it?

        /* Reset signals in the child */


        signal(SIGALRM, SIG_DFL);
        signal(SIGHUP,  SIG_DFL);
        signal(SIGCHLD, SIG_DFL);


My test results (and source code):

# ./forkalrm
Parent is 5193 and child 5194.
5194 got SIGALRM.
5193 got SIGALRM.
5194 got SIGALRM.
Process 5194 exiting normally.
5193 got SIGALRM.
Process 5193 exiting normally.

--- begin forkalrm.c ---
#include <unistd.h>
#include <signal.h>
#include <sys/poll.h>
#include <errno.h>

void sigalrm();

int     pid;


main()
{
        int     i;


        signal(SIGALRM, sigalrm);
        i = fork();
        pid = getpid();
        if (i)
                printf("Parent is %u and child %u.\n", pid, i);
        alarm(10);
        poll(NULL,0,15000);
        if (errno==EINTR) {
                alarm(5);
                poll(NULL,0,10000);
        }
        printf("Process %u exiting normally.\n", pid);
}


void sigalrm()
{
        printf("%u got SIGALRM.\n", pid);
}
--- end forkalrm.c ---