home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GEMini Atari
/
GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso
/
zip
/
gnu
/
tests.lzh
/
TESTS
/
TSIGNL.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-29
|
928b
|
60 lines
#include "ansidecl.h"
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef __USE_GNU
#ifdef atarist
#include <siglist.h>
#define strsignal(s) signal_names[(s)]
#else
#define strsignal(s) ("signal FOO")
#endif
#endif
#ifndef __USE_GNU
#ifdef sun
#define raise(X) kill(getpid(), X)
#endif
#endif
int win = 0;
void
DEFUN(handler, (sig), int sig)
{
printf("Received signal %d (%s).\n", sig, strsignal(sig));
win = 1;
}
int
DEFUN_VOID(main)
{
if (signal(SIGINT, handler) == SIG_ERR)
{
perror("signal: SIGINT");
return(EXIT_FAILURE);
}
puts("Set handler.");
printf("Sending myself signal %d.\n", SIGINT);
fflush(stdout);
if (raise(SIGINT) < 0)
{
perror("raise: SIGINT");
return(EXIT_FAILURE);
}
if (!win)
{
puts("Didn't get any signal.");
return(EXIT_FAILURE);
}
puts("Got a signal.");
return(EXIT_SUCCESS);
}