Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* resposta a sinais (signal)
- comando ps para obter o <id processo>
- kill <id processo> : emite mensagem "sinal recebido"
- kill -USR1 <id processo> : ignorado
- kill -INT <id processo> : termina programa */
- // Apple Xcode
- // paulogp
- #include <stdio.h>
- #include <signal.h>
- void responder(int signum)
- {
- printf("sinal recebido\n");
- }
- int main (int argc, const char * argv[])
- {
- printf("activo\n");
- struct sigaction the_action;
- sigset_t the_sigset;
- the_action.sa_handler = responder;
- sigaction(SIGUSR1, &the_action, NULL);
- sigaction(SIGTERM, &the_action, NULL);
- sigemptyset(&the_sigset);
- sigaddset(&the_sigset, SIGUSR1);
- sigprocmask(SIG_SETMASK, &the_sigset, NULL);
- while (1); // infinite loop
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement