Jump to content

catching sigterm

- - - - -

  • Please log in to reply
2 replies to this topic

#1
eafkuor

eafkuor

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 218 posts
I have this:


void handler(int signum){

    printf("sigterm catched\n");

    exit(0);

}



int main(int argc, char *argv[]){

    struct sigaction sa;

		

    sa.sa_handler = handler;

    sigemptyset(&sa.sa_mask);

    sa.sa_flags = SA_RESTART;


    if (sigaction(SIGTERM, &sa, NULL) == -1){

        printf("sigaction error\n");

    	return 1;

    }

    

    while(1);



	return 0;

}

But when I type ctrl+c handler() is not executed. Help?

#2
eafkuor

eafkuor

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 218 posts
Nevermind, ctrl+c is SIGINT :c-smirk:

#3
ximenation

ximenation

    Newbie

  • Members
  • Pip
  • 1 posts
thank you!!! it's




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users