Dmitry V. Levin
66a15a5bb8
Since "struct sigaction" varies between architectures, rt_sigaction decoding sometimes produces incorrect output. This test is expected to catch basic rt_sigaction decoding bugs. Based on a patch proposed by Chris Dearman. * tests/sigaction.c: New file. * tests/sigaction.awk: Likewise. * tests/sigaction.sh: New test. * tests/Makefile.am (check_PROGRAMS): Add sigaction. (TESTS): Add sigaction.sh. (EXTRA_DIST): Add sigaction.awk. * tests/.gitignore: Add sigaction.
37 lines
703 B
C
37 lines
703 B
C
#include <assert.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <signal.h>
|
|
|
|
static void handle_signal(int no)
|
|
{
|
|
_exit(128 + no);
|
|
}
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
struct sigaction sa, sa1, sa2, sa3;
|
|
|
|
sa.sa_handler = SIG_IGN;
|
|
sigemptyset(&sa.sa_mask);
|
|
sigaddset(&sa.sa_mask, SIGHUP);
|
|
sigaddset(&sa.sa_mask, SIGINT);
|
|
sa.sa_flags = SA_RESTART;
|
|
assert(!sigaction(SIGUSR2, &sa, &sa1));
|
|
|
|
sa.sa_handler = handle_signal;
|
|
sigemptyset(&sa.sa_mask);
|
|
sigaddset(&sa.sa_mask, SIGQUIT);
|
|
sigaddset(&sa.sa_mask, SIGTERM);
|
|
sa.sa_flags = SA_SIGINFO;
|
|
assert(!sigaction(SIGUSR2, &sa, &sa2));
|
|
|
|
sa.sa_handler = SIG_DFL;
|
|
sigemptyset(&sa.sa_mask);
|
|
sa.sa_flags = 0;
|
|
assert(!sigaction(SIGUSR2, &sa, &sa3));
|
|
|
|
return 0;
|
|
}
|