Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 Feb 2008 11:32:28 +0100
From:      Remko Lodder <remko@FreeBSD.org>
To:        =?UTF-8?B?Q2loYW4gS8O2bWXDp2/En2x1?= <cihan@enderunix.org>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: abort?
Message-ID:  <47AED2BC.2080505@FreeBSD.org>
In-Reply-To: <1623050662.20080210122354@enderunix.org>
References:  <1623050662.20080210122354@enderunix.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Cihan Kömeçoğlu wrote:
> Hello list
> 
> I cant understand why kill function is called two times to send
> sigabort signal. One signal to send is enough, isn't it?
> 
> Thanks
> 
> 
> 
> void
> abort(void)         /* POSIX-style abort() function */
> {
>     sigset_t           mask;
>     struct sigaction   action;
> 
>     /*
>      * Caller can't ignore SIGABRT, if so reset to default.
>      */
>     sigaction(SIGABRT, NULL, &action);
>     if (action.sa_handler == SIG_IGN) {
>         action.sa_handler = SIG_DFL;
>         sigaction(SIGABRT, &action, NULL);
>     }
>     if (action.sa_handler == SIG_DFL)
>         fflush(NULL);           /* flush all open stdio streams */
> 
>     /*
>      * Caller can't block SIGABRT; make sure it's unblocked.
>      */
>     sigfillset(&mask);
>     sigdelset(&mask, SIGABRT);  /* mask has only SIGABRT turned off */
>     sigprocmask(SIG_SETMASK, &mask, NULL);
>     kill(getpid(), SIGABRT);    /* send the signal */
       ^^^^^ kill 1
> 
>     /*
>      * If we're here, process caught SIGABRT and returned.
>      */
>     fflush(NULL);               /* flush all open stdio streams */
>     action.sa_handler = SIG_DFL;
>     sigaction(SIGABRT, &action, NULL);  /* reset to default */
>     sigprocmask(SIG_SETMASK, &mask, NULL);  /* just in case ... */
>     kill(getpid(), SIGABRT);                /* and one more time */
       ^^^^ kill 2

>     exit(1);    /* this should never be executed ... */
> }
>  
> 

Just a wild guess... but if you read the above you'll see two kill 
statements, without conditionals around it, so my guess is that
even when the signal had already been send (kill 1), the information
regarding the pid etc remains in memory, and when you traverse the code,
it sends it again (kill 2).

my E0.02

-- 
/"\   Best regards,                      | remko@FreeBSD.org
\ /   Remko Lodder                       | remko@EFnet
  X    http://www.evilcoder.org/          |
/ \   ASCII Ribbon Campaign              | Against HTML Mail and News



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?47AED2BC.2080505>