| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#include <config.h> |
| 20 |
|
| 21 |
#include <signal.h> |
| 22 |
|
| 23 |
#include "signature.h" |
| 24 |
SIGNATURE_CHECK (sigprocmask, int, (int, const sigset_t *, sigset_t *)); |
| 25 |
|
| 26 |
#include <errno.h> |
| 27 |
#include <stdio.h> |
| 28 |
#include <stdlib.h> |
| 29 |
#include <unistd.h> |
| 30 |
|
| 31 |
#include "macros.h" |
| 32 |
|
| 33 |
#if !(defined _WIN32 && !defined __CYGWIN__) |
| 34 |
|
| 35 |
static volatile int sigint_occurred; |
| 36 |
|
| 37 |
static void |
| 38 |
sigint_handler (int sig) |
| 39 |
{ |
| 40 |
sigint_occurred++; |
| 41 |
} |
| 42 |
|
| 43 |
int |
| 44 |
main (int argc, char *argv[]) |
| 45 |
{ |
| 46 |
sigset_t set; |
| 47 |
pid_t pid = getpid (); |
| 48 |
char command[80]; |
| 49 |
|
| 50 |
if (sizeof (int) < sizeof pid && 0x7fffffff < pid) |
| 51 |
{ |
| 52 |
fputs ("Skipping test: pid too large\n", stderr); |
| 53 |
return 77; |
| 54 |
} |
| 55 |
|
| 56 |
signal (SIGINT, sigint_handler); |
| 57 |
|
| 58 |
sigemptyset (&set); |
| 59 |
sigaddset (&set, SIGINT); |
| 60 |
|
| 61 |
|
| 62 |
ASSERT (sigprocmask (1729, &set, NULL) == -1); |
| 63 |
ASSERT (errno == EINVAL); |
| 64 |
|
| 65 |
|
| 66 |
ASSERT (sigprocmask (SIG_BLOCK, &set, NULL) == 0); |
| 67 |
|
| 68 |
|
| 69 |
sprintf (command, "sh -c 'sleep 1; kill -%d %d' &", SIGINT, (int) pid); |
| 70 |
ASSERT (system (command) == 0); |
| 71 |
|
| 72 |
|
| 73 |
sleep (2); |
| 74 |
|
| 75 |
|
| 76 |
ASSERT (sigint_occurred == 0); |
| 77 |
|
| 78 |
|
| 79 |
ASSERT (sigprocmask (SIG_UNBLOCK, &set, NULL) == 0); |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
ASSERT (sigint_occurred == 1); |
| 86 |
|
| 87 |
return 0; |
| 88 |
} |
| 89 |
|
| 90 |
#else |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
int |
| 96 |
main () |
| 97 |
{ |
| 98 |
fputs ("Skipping test: native Windows platform\n", stderr); |
| 99 |
return 77; |
| 100 |
} |
| 101 |
|
| 102 |
#endif |