.. | ||
child_functions.c | ||
child_functions.h | ||
Makefile | ||
README.md | ||
task_2_1.c | ||
task_2_2.c | ||
task_2_3.c | ||
task_2_4.c |
Topic 2 – Forking
Task 1
Write a simple program, where you create one child process.
Parent proces should write a "I am a parent" message, while your child process should write "I am a child".
man 2 fork
Task 2
Please extend last program - make both processes display their process ID (PID) and their parent's PID.
man 2 getpid man 2 getppid
Task 3
Modify last program, so that it creates not one but 5 child processes.
Task 4
Go back to the code from Task 2 (with one child process)
Please check, what happens when
-
parent finishes execution before its child
-
child finishes execution before its parent
Use sleep(..) function to force a delaay.
You can check process state using ps -f <pid>
command