/*
 * Signal test; 
 * tests control-C handling
 */

#include <signal.h>
#include <stdio.h>
#include <errno.h>


static int handler( int signr )
{
    printf(" IN HANDLER, signr=%d\n", signr );  
}

#define D(x) if (x) { printf("System call failure : " #x " errno=%d\n", errno); }


main() {
    int ret;
    struct sigaction act;

    act.sa_handler= handler;
    act.sa_flags  = 0;
    sigemptyset(&act.sa_mask);

    D( sigaction( SIGINT, &act, 0) );

    printf("Waiting for control C...\n");
    ret = sigsuspend(&act.sa_mask);
    if (ret) {
	if (errno != EINTR)
	    printf("System call failure: sigsuspend(): errno=%d\n", errno);
    }

    printf(" PROCESS TERMINATED\n");   
}
