Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _GNU_SOURCE
- #include <stdio.h>
- #include <unistd.h>
- //
- int main(){
- pid_t grandpa_pid = getpid();
- pid_t child_pid;
- if ((child_pid = fork()) == 0){
- pid_t parent_pid = getpid();
- pid_t child_child_pid;
- if ((child_child_pid = fork()) == 0) {
- usleep(200);
- printf("Procesul nepot cu pid %d, pid copil %d , pid nepot %d .", getpid(), parent_pid, grandpa_pid);
- } else {
- usleep(100);
- printf("Procesul copil cu pid %d, pid nepot %d , pid parinte %d .", getpid(), child_child_pid, grandpa_pid);
- }
- } else {
- printf("Procesul parinte cu pid %d si pid copil %d.", getpid(), child_pid);
- }
- printf("\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement