sigstackgrowth.c revision c45282ada5d2fc41c3a968bf03b0caa51b426b44
1#include <signal.h> 2#include <stdio.h> 3#include <stdlib.h> 4#include <sys/types.h> 5#include <unistd.h> 6 7static char *deep; 8 9#define SIZE (4*1024*1024) 10 11static void handler(int sig) 12{ 13 char here; 14 15 if (&here < deep) { 16 printf("PASSED\n"); 17 exit(0); 18 } 19 20 kill(getpid(), SIGUSR1); 21} 22 23int main() 24{ 25 struct sigaction sa; 26 27 char here; 28 deep = &here - SIZE; 29 30 sa.sa_handler = handler; 31 sa.sa_flags = SA_NOMASK; 32 sigemptyset(&sa.sa_mask); 33 34 sigaction(SIGUSR1, &sa, NULL); 35 36 kill(getpid(), SIGUSR1); 37 38 printf("FAILED\n"); 39 exit(1); 40} 41