aboutsummaryrefslogtreecommitdiff
path: root/semestr-5/so/lista1/rozwiazania/ex2b.c
diff options
context:
space:
mode:
Diffstat (limited to 'semestr-5/so/lista1/rozwiazania/ex2b.c')
-rw-r--r--semestr-5/so/lista1/rozwiazania/ex2b.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/semestr-5/so/lista1/rozwiazania/ex2b.c b/semestr-5/so/lista1/rozwiazania/ex2b.c
new file mode 100644
index 0000000..af4a986
--- /dev/null
+++ b/semestr-5/so/lista1/rozwiazania/ex2b.c
@@ -0,0 +1,21 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+int main() {
+ int pid = fork();
+ if (pid < 0) {
+ printf("Fork error\n");
+ exit(1);
+ }
+ if (pid == 0) {
+ printf("[%d], Child process, returning.\n", getpid());
+ exit(0);
+ }
+ else {
+ while (1) {
+ printf("[%d] Parent process, sleeping.\n", getpid());
+ sleep(1);
+ }
+ }
+} \ No newline at end of file