[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sigaction test failure on FreeBSD 9.1 when pthread is used
From: |
Paul Eggert |
Subject: |
Re: sigaction test failure on FreeBSD 9.1 when pthread is used |
Date: |
Mon, 29 Apr 2013 15:57:43 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130311 Thunderbird/17.0.4 |
On 04/29/13 12:09, Ed Maste wrote:
> If my understanding is correct your replacement test case should still
> pass even with the following change:
>
> - sa.sa_flags = SA_RESETHAND | SA_NODEFER;
> + sa.sa_flags = SA_RESETHAND | SA_NODEFER | SA_SIGINFO;
Not exactly, since in that case one also needs to change
the signature of the handler, and assign to the sa_sigaction
member instead of to the sa_handler member. Here's the
test case with those fixes.
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
static void
handler (int sig, siginfo_t *info, void *context)
{
struct sigaction sa;
if (sigaction (SIGABRT, 0, &sa) != 0)
perror ("handler sigaction"), _exit (1);
if (sa.sa_flags & SA_SIGINFO)
{
static char const msg[] = "handler sigaction wrongly reports
SA_SIGINFO\n";
write (STDERR_FILENO, msg, sizeof msg - 1);
_exit (1);
}
if (sa.sa_handler != SIG_DFL)
{
static char const msg[] = "handler sa_handler is not SIG_DFL\n";
write (STDERR_FILENO, msg, sizeof msg - 1);
_exit (1);
}
}
int
main (void)
{
struct sigaction sa;
sa.sa_flags = SA_RESETHAND | SA_NODEFER | SA_SIGINFO;
sa.sa_sigaction = handler;
if (sigemptyset (&sa.sa_mask) != 0)
return perror ("sigemptyset"), 1;
if (sigaction (SIGABRT, &sa, 0) != 0)
return perror ("sigaction"), 1;
if (raise (SIGABRT) != 0)
return perror ("raise"), 1;
return 0;
}