How do i remove a signal handler
Asked Answered
D

1

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.

Datha answered 15/2, 2012 at 22:25 Comment(0)
A
21

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

Artie answered 15/2, 2012 at 22:34 Comment(2)
or just replace the existing signal handler with your new one; no need to remove the old one first.Transcendent
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.Prussian

© 2022 - 2024 — McMap. All rights reserved.