AAE-CNAS-Labs/Topic-3-Forking/README.md

35 lines
740 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Topic 3 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
1. parent finishes execution before its child
2. child finishes execution before its parent
Use sleep(..) function to force a delaay.
You can check process state using `ps -f <pid>` command