PtAppAddSignalProc

I am trying to use “PtAppAddSignalProc”. Perhaps,I am using it incorrectly
and so it doesnt invoke the signal handler.

Can someone briefly describe how to use it? Or it would be even better, if
someone could post some code examples.

Thanks for your help

Shashank

Shashank wrote:

I am trying to use “PtAppAddSignalProc”. Perhaps,I am using it incorrectly
and so it doesnt invoke the signal handler.

It’s pretty straightforward, isn’t it… On detail that may not be
entirely obvious is that it relies on the main loop. Are you running
PtMainLoop()?

Can someone briefly describe how to use it? Or it would be even better, if
someone could post some code examples.

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

static int sigcatcher( int sig, void *data ) {
printf( “Got signal #%d\n”, sig );
PtExit( 0 );
return Pt_CONTINUE;
}

int main( void ) {
if ( PtInit(NULL) )
perror(“PtInit”);
else {
sigset_t ss;
sigemptyset( &ss );
sigaddset( &ss, SIGINT );
sigaddset( &ss, SIGHUP );
sigaddset( &ss, SIGQUIT );
PtAppAddSignalProc( NULL, &ss, sigcatcher, NULL );
PtMainLoop();
}
return 1;
}