Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Zademonstruj w jaki sposób mog ą powsta ć w systemie procesy zombie.
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- int main(void)
- {
- pid_t pid;
- pid = fork();
- if(pid == 0){
- // child
- printf("Rodzic potomny zakonczyl swoje dzialanie, potomny zostal procesem zombie");
- while(1){
- sleep(2);
- printf("Proces Zombie, aby zakonczyc proces wpisz \"kill %d\"\n", getpid());
- }
- }
- else if(pid > 0){
- // parent
- printf("Konczenie procesu rodzcielskiego\n");
- }
- else{
- perror("fork");
- return EXIT_FAILURE;
- }
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement