zajecia10
This commit is contained in:
parent
20d277ffcf
commit
8861a640e7
BIN
zajecia10/lab_fork
Executable file
BIN
zajecia10/lab_fork
Executable file
Binary file not shown.
14
zajecia10/lab_fork.c
Normal file
14
zajecia10/lab_fork.c
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
int res = fork();
|
||||||
|
if(res>0){
|
||||||
|
printf("Jestem rodzicem [%d] [%d]\n", res, getpid());
|
||||||
|
res=wait(NULL);
|
||||||
|
printf("Zakonczono proces [%d]\n", res);
|
||||||
|
}
|
||||||
|
else if (res == 0){
|
||||||
|
printf("Jestem potomkiem [%d] [%d]\n", res, getpid());
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
BIN
zajecia10/lab_orphan
Executable file
BIN
zajecia10/lab_orphan
Executable file
Binary file not shown.
13
zajecia10/lab_orphan.c
Normal file
13
zajecia10/lab_orphan.c
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
int res = fork();
|
||||||
|
if(res == 0){
|
||||||
|
sleep(100);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
printf("Parent\n");
|
||||||
|
sleep(10);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user