Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Aby procesy potomne nie stawały się procesami zombie wystarczy, żeby proces
- macierzysty ignorował sygnał SIGCHLD. Napisz program, który sprawdzi, czy
- rzeczywiście tak się dzieje i co w takim przypadku zwraca wait() lub waitpid() po
- zakończeniu potomka.
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <signal.h>
- #include <wait.h>
- int main(void)
- {
- pid_t pid;
- pid = fork();
- if(pid == -1){
- perror("fork");
- return EXIT_FAILURE;
- }
- else if(pid == 0){
- printf("Koniec potmoka\n");
- }
- else{
- if(signal(SIGCHLD, SIG_IGN) == SIG_ERR){
- perror("signal");
- return EXIT_FAILURE;
- }
- printf("Po zakonczeniu potomka funkcja wait zwraca: %d - czyli blad\n", wait(NULL));
- }
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement