Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Napisz program, który stworzy dwa procesy. Proces macierzysty powinien poczekać
- na wykonanie procesu potomnego i zbadać status jego wyjścia.
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <sys/types.h>
- #include <sys/wait.h>
- int main(void)
- {
- int wstatus;
- pid_t pid = fork();
- if(pid == 0){
- // Potomek
- }
- else if(pid > 0){
- // Rodzic
- wait(&wstatus);
- printf("Potomek zakonczyl dzialanie ze statusem wyjscia: %d\n", wstatus);
- }
- else{
- perror("fork");
- return EXIT_FAILURE;
- }
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement