It looks like you're new here. If you want to get involved, click one of these buttons!
#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<signal.h>
void sighandler(int signum)
{
switch( signum )
{
case SIGTERM:
printf(\"SIGTERM received\n\");
break;
case SIGINT:
printf(\"SIGINT Received\n\");
break;
case SIGCONT:
printf(\"SIGCONT Received\n\");
break;
}
}
int main()
{
char buffer[ 80 ]=\"\0\";
sigset_t block;
signal( SIGTERM,sighandler );
signal( SIGINT,sighandler );
signal( SIGCONT,sighandler);
sigemptyset(&block);
sigaddset( &block,SIGTERM);
sigaddset( &block,SIGINT);
sigprocmask( SIG_BLOCK,&block,NULL);
while ( strcmp(buffer,\"n\")!=0)
{
printf(\"enter a string:\");
gets(buffer);
puts(buffer);
}
sigprocmask(SIG_UNBLOCK,&block,NULL);
while(1)
printf(\"\rProgram running\");
}