-
Notifications
You must be signed in to change notification settings - Fork 0
/
pid2.c
45 lines (39 loc) · 783 Bytes
/
pid2.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char* argv[])
{
fprintf(stdout, "Proces\tPotomek\n");
fprintf(stdout, "______\t_______\n");
int pid = fork();
if(pid == 0)
{
pid = fork();
if(pid != 0)
{
pid = fork();
if(pid != 0)
{
pid = fork();
sleep(5);
}
sleep(4);
}
sleep(3);
}
else{
pid = fork();
if(pid == 0)
{
pid = fork();
sleep(6);
}
}
pid = wait(NULL);
int pid2 = getpid();
fprintf(stdout, "%d\t", getppid());
fprintf(stdout, "%d\n", getpid());
pid = wait(NULL);
exit(0);
}