1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
#include <config.h>
#include <signal.h>
#include "signature.h"
SIGNATURE_CHECK (sigaction, int, (int, struct sigaction const *,
struct sigaction *));
#include <stddef.h>
#include "macros.h"
#ifndef SA_NOCLDSTOP
# define SA_NOCLDSTOP 0
#endif
#ifndef SA_ONSTACK
# define SA_ONSTACK 0
#endif
#ifndef SA_RESETHAND
# define SA_RESETHAND 0
#endif
#ifndef SA_RESTART
# define SA_RESTART 0
#endif
#ifndef SA_SIGINFO
# define SA_SIGINFO 0
#endif
#ifndef SA_NOCLDWAIT
# define SA_NOCLDWAIT 0
#endif
#define MASK_SA_FLAGS (SA_NOCLDSTOP | SA_ONSTACK | SA_RESETHAND | SA_RESTART \
| SA_SIGINFO | SA_NOCLDWAIT | SA_NODEFER)
static void
handler (int sig)
{
static int entry_count;
struct sigaction sa;
ASSERT (sig == SIGABRT);
ASSERT (sigaction (SIGABRT, NULL, &sa) == 0);
ASSERT ((sa.sa_flags & SA_SIGINFO) == 0);
switch (entry_count++)
{
case 0:
ASSERT ((sa.sa_flags & SA_RESETHAND) == 0);
ASSERT (sa.sa_handler == handler);
break;
case 1:
#if !(defined __GLIBC__ || defined __UCLIBC__)
ASSERT (sa.sa_handler == SIG_DFL);
#endif
break;
default:
ASSERT (0);
}
}
int
main (void)
{
struct sigaction sa;
struct sigaction old_sa;
sa.sa_handler = handler;
sa.sa_flags = 0;
ASSERT (sigemptyset (&sa.sa_mask) == 0);
ASSERT (sigaction (SIGABRT, &sa, NULL) == 0);
ASSERT (raise (SIGABRT) == 0);
sa.sa_flags = SA_RESETHAND | SA_NODEFER;
ASSERT (sigaction (SIGABRT, &sa, &old_sa) == 0);
ASSERT ((old_sa.sa_flags & MASK_SA_FLAGS) == 0);
ASSERT (old_sa.sa_handler == handler);
ASSERT (raise (SIGABRT) == 0);
sa.sa_handler = SIG_DFL;
ASSERT (sigaction (SIGABRT, &sa, &old_sa) == 0);
ASSERT ((old_sa.sa_flags & SA_SIGINFO) == 0);
#if !(defined __GLIBC__ || defined __UCLIBC__)
ASSERT (old_sa.sa_handler == SIG_DFL);
#endif
sa.sa_handler = SIG_IGN;
ASSERT (sigaction (SIGABRT, &sa, NULL) == 0);
ASSERT (raise (SIGABRT) == 0);
ASSERT (sigaction (SIGABRT, NULL, &old_sa) == 0);
ASSERT (old_sa.sa_handler == SIG_IGN);
ASSERT (raise (SIGABRT) == 0);
return 0;
}
|