EmbLogic's Blog

signal problems:

#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<signal.h>

void outch(int sig)
{
printf(“outch:i got a signal no.=%d\n”,sig);
sleep(5);

printf(“handler for signal no.=%d has ended\n”,sig);
}

int main()
{
struct sigaction act,act1;
act.sa_handler=outch;
sigemptyset(&act.sa_mask);
sigaddset(&act.sa_mask,SIGQUIT);
sigaction(SIGINT,&act,0);
sigaction(SIGQUIT,&act,0);

act1.sa_handler=outch;
sigemptyset(&act1.sa_mask);

sigaddset(&act1.sa_mask,SIGTSTP);

sigprocmask(SIG_BLOCK,&act1.sa_mask,&act.sa_mask);

while(1)
{
printf(“hello\n”);
sleep(1);
}
return 0;
}
in the above prog. SIG_BLOCK is not doing union of old & new mask.

5 Responses to signal problems:

  1. Mandar says:

    i think Kuldeep is right…

  2. virender says:

    u have given wrong argument in sigaction .so u must follow the document

  3. shyam.singh says:

    mention that logical problem….

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>