Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<stdio.h>
- #include<time.h>
- #include<stdlib.h>
- #include<unistd.h>
- #include<sys/shm.h>
- #include<signal.h>
- #include<sys/ipc.h>
- #include<sys/wait.h>
- #include<sys/types.h>
- #include<unistd.h>
- #include<pthread.h>
- using namespace std;
- void otac(int i)
- {
- printf("ja sam otac \n");
- }
- void sin(int i)
- {
- printf("ja sam sin \n");
- }
- void unuk(int i)
- {
- printf("ja sam unuk \n");
- }
- int main()
- {
- int i;
- switch (fork())
- {
- case -1: cout<<"greska tijeko stvaranja"<<endl;
- exit(0);
- case 0:
- otac(i);
- switch(fork())
- {
- case -1: cout<<"greska!"<<endl;
- case 0: sin(i);
- switch(fork())
- {
- case 0: unuk(i);
- case -1: break;
- exit(0);
- }
- exit(0);
- default: break;
- }
- exit(0);
- default:break;
- }
- wait(NULL);
- sleep(6);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement