Philippe Waroquiers 95a346248f Fix MacOS passsigalrm.c compilation error due to SIGRTMIN not existing on MacOS
The test will very probably fail on MacOS (as gdb output will contain SIGUSR1
rather than signal SIGRTMIN, but at least it should compile).
(not tested on MacOS; just tested that it still works on linux)



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12594
2012-05-29 17:04:13 +00:00

70 lines
1.7 KiB
C

#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
static int sigalrm_received = 0;
static void sigalrm_handler(int signr)
{
sigalrm_received++;
}
static int sigrtmin_received = 0;
static void sigrtmin_handler(int signr)
{
sigrtmin_received++;
}
static int breakme = 0;
#ifndef SIGRTMIN
// at least on MacOS, there is no SIGRTMIN.
// So, use any other signal instead.
#define SIGRTMIN SIGUSR1
#endif
int main (int argc, char *argv[])
{
struct sigaction sa;
fprintf(stderr, "starting ...\n");
sa.sa_handler = sigalrm_handler;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
if (sigaction (SIGALRM, &sa, NULL) != 0)
perror("sigaction");
if (kill(getpid(), SIGALRM) != 0)
perror("kill 1");
if (sigalrm_received == 1)
fprintf (stderr, "ok: 1st SIGALRM received\n");
else
fprintf (stderr, "wrong 1st: unexpected value %d sigalrm_received\n",
sigalrm_received);
if (kill(getpid(), SIGALRM) != 0)
perror("kill 2");
if (sigalrm_received == 2)
fprintf (stderr, "ok: 2nd SIGALRM received\n");
else
fprintf (stderr, "wrong 2nd: unexpected value %d sigalrm_received\n",
sigalrm_received);
system("../tests/true");
breakme++;
sa.sa_handler = sigrtmin_handler;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
if (sigaction (SIGRTMIN, &sa, NULL) != 0)
perror("sigaction");
if (kill(getpid(), SIGRTMIN) != 0)
perror("kill sigrtmin");
if (sigrtmin_received == 1)
fprintf (stderr, "ok: SIGRTMIN received\n");
else
fprintf (stderr, "wrong sigrtmin: unexpected value %d sigrtmin_received\n",
sigrtmin_received);
return 0;
}