diff --git a/zajecia10/lab_fork b/zajecia10/lab_fork new file mode 100755 index 0000000..8c08542 Binary files /dev/null and b/zajecia10/lab_fork differ diff --git a/zajecia10/lab_fork.c b/zajecia10/lab_fork.c new file mode 100644 index 0000000..21d4406 --- /dev/null +++ b/zajecia10/lab_fork.c @@ -0,0 +1,14 @@ +#include + +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; +} diff --git a/zajecia10/lab_orphan b/zajecia10/lab_orphan new file mode 100755 index 0000000..84e86c4 Binary files /dev/null and b/zajecia10/lab_orphan differ diff --git a/zajecia10/lab_orphan.c b/zajecia10/lab_orphan.c new file mode 100644 index 0000000..ebab70d --- /dev/null +++ b/zajecia10/lab_orphan.c @@ -0,0 +1,13 @@ +#include + +int main(){ + int res = fork(); + if(res == 0){ + sleep(100); + } + else{ + printf("Parent\n"); + sleep(10); + } + return 0; +}