From 883456d09506e480af6d5014665144895ba90072 Mon Sep 17 00:00:00 2001 From: Fabio Scotto di Santolo Date: Tue, 1 Jul 2025 10:56:08 +0200 Subject: [PATCH] Added README files --- README.md | 3 ++- chp5/README.md | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 chp5/README.md diff --git a/README.md b/README.md index ee607a1..36289eb 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,10 @@ Welcome! This is a collection of chapter summaries from the book **Linux System - [Chapter 2 – File I/O](chp2/README.md) - [Chapter 3 – Buffered I/O](chp3/README.md) - [Chapter 4 – Advanced File I/O](chp4/README.md) +- [Chapter 5 - Process Management](chp5/README.md) > Each file contains an English summary of the chapter's key concepts. ## License -This project is licensed under the [MIT License](./LICENSE). \ No newline at end of file +This project is licensed under the [MIT License](./LICENSE). diff --git a/chp5/README.md b/chp5/README.md new file mode 100644 index 0000000..52c26da --- /dev/null +++ b/chp5/README.md @@ -0,0 +1,73 @@ +# 📘 Chapter 5 – Process Management (Summary) +**Based on _Linux System Programming_ by Robert Love** + +This chapter covers how Linux manages processes, including their creation, execution, and termination. It introduces key system calls and concepts that underpin multitasking and process control in Unix-like systems. + +--- + +## 🧠 Core Concepts +- A **process** is an independent program with its own memory and execution context. +- The kernel provides **process abstraction** to manage concurrency. +- Processes are scheduled and isolated using virtual memory and process control blocks (PCBs). + +--- + +## 🛠️ Process Creation & Termination +- `fork()` creates a new process (child) by duplicating the calling (parent) process using **copy-on-write**. +- `exec()` replaces the current process image with a new program. +- `wait()` and `waitpid()` allow the parent to wait for and collect the child’s exit status. +- `exit()` performs cleanup and exits the process gracefully. +- `_exit()` exits immediately without flushing stdio buffers. + +--- + +## 🔍 Signals & Zombies +- **Zombie processes** occur when a child exits but the parent doesn’t read its status with `wait()`. +- `SIGCHLD` is sent to the parent when a child terminates. +- The `init` process (PID 1) will adopt and clean up orphaned children. + +--- + +## 👥 Process Hierarchies +- Every process has a unique **PID** and a **PPID** (parent PID). +- Together they form a **process tree**, starting from `init`. +- Tools like `ps`, `pstree`, and `/proc` are useful for visualizing process hierarchies. + +--- + +## 🎯 Process Identifiers & Groups +- `getpid()` returns the process’s ID. +- `getppid()` returns the parent’s ID. +- **Process groups** and **sessions** enable job control, allowing signals to be sent to multiple related processes. + +--- + +## 🧩 Resource Cleanup +- On termination, the kernel reclaims: + - Memory + - Open file descriptors + - IPC resources +- `exit()` also triggers: + - `atexit()` handlers + - Standard I/O flushes + - Potential creation of core dumps (if enabled) + +--- + +## ✅ Why This Matters +A strong understanding of process control is essential for: +- Writing daemons +- Managing background jobs +- Building shells or supervisors +- Avoiding resource leaks and zombie processes + +--- + +## 📚 References +- _Linux System Programming_, 2nd Edition by Robert Love (O'Reilly) +- `man 2 fork`, `man 2 execve`, `man 2 wait`, `man 2 exit`, `man 7 signal` + +--- + +*This summary is for educational purposes.* +