How to handle Multiple Signals In
Linux Based C Prorogram
Linux Based C Prorogram
# include
# include
# include
void inthandler ( int signum )
{
printf ( "\nSIGINT Received\n" ) ;
}
void termhandler ( int signum )
{
printf ( "\nSIGTERM Received\n" ) ;
}
void conthandler ( int signum )
{
printf ( "\nSIGCONT Received\n" ) ;
}
int main( )
{
signal ( SIGINT, inthandler ) ;
signal ( SIGTERM, termhandler ) ;
signal ( SIGCONT, conthandler ) ;
while ( 1 )
printf ( "\rProgram Running" ) ;
return 0 ;
}
signal() shouldn't be used any more, as it's not portable. Look up sigaction() in your local manual, section 2.
ReplyDelete