16

I've made the follow signal handler

struct sigaction pipeIn;
pipeIn.sa_handler = updateServer;
sigemptyset(&pipeIn.sa_mask);
sa.sa_flags = SA_RESTART;

if(sigaction(SIGUSR1, &pipeIn, NULL) == -1){

    printf("We have a problem, sigaction is not working.\n");
    perror("\n");
    exit(1);    

}

How do I remove or block this particular handler so that I can set up another signal handler that uses the same signal? Thanks.

Dr.Knowitall
  • 10,080
  • 23
  • 82
  • 133

1 Answers1

21

Use SIG_DFL in place of the function pointer when calling sigaction(2).

Nikolai Fetissov
  • 82,306
  • 11
  • 110
  • 171
  • 3
    or just replace the existing signal handler with your new one; no need to remove the old one first. – mark4o Feb 16 '12 at 01:27
  • if you just want to remove the signal handler (I found an example where I was getting circular signals) then `signal(SIGUSR1, SIG_DFL);` is equivalent without the awkwardness of the struct sigaction. – Michael Malone Aug 27 '20 at 02:59