Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Pokaż w jaki sposób sygnały mogą być przez proces blokowane lub ignorowane.
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <signal.h>
- #include <wait.h>
- int main(void)
- {
- pid_t pid;
- if(signal(SIGINT, SIG_IGN) == SIG_ERR){
- perror("signal");
- return EXIT_FAILURE;
- }
- pid = fork();
- if(pid == -1){
- perror("fork");
- return EXIT_FAILURE;
- }
- else if(pid == 0){
- kill(getppid(), SIGINT);
- }
- else{
- wait(NULL);
- printf("Sygnal SIGINT jest ignorowany, koniec programu za 3 sekundy\n");
- sleep(3);
- printf("\n");
- }
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement