Demystifying Processes and Signals in Unix

Cover Image for Demystifying Processes and Signals in Unix

In the intricate realm of Unix systems, processes and signals wield tremendous power, enabling efficient multitasking and communication between programs. Delve into the intricacies of these concepts to navigate your Unix environment with mastery.

The PID Unveiled: Process Identification

Objective: Grasp the essence of Process IDs (PIDs) and their significance in managing processes.

What's a PID?: A Process ID is a unique number assigned to each process running in a Unix-like operating system.

Locating a PID:

ps aux | grep "process_name"

Taming Processes: An Exploration

Objective: Understand the concept of processes and how to manage them using their PIDs.

Defining a Process: A process is an instance of a running program that has its own memory space and resources.

Terminating a Process:

kill <PID>

Navigating Signals: The Messaging System

Objective: Grasp the concept of signals, which are asynchronous notifications sent between processes.

What's a Signal?: A signal is a software interrupt delivered to a process to notify it of a particular event.

Signals with Power: Two signals that cannot be ignored are:

  • SIGKILL (9): Forcibly terminates a process.

  • SIGSTOP (19): Suspends a process.

Mastering Signal Delivery and Handling

Objective: Understand how signals are delivered and how processes can handle them.

Delivering Signals:

kill -<signal> <PID>

Signal Handling:

trap "echo Signal received; exit" SIGINT SIGTERM

The world of Unix processes and signals is a tapestry of multitasking and communication. PIDs serve as unique identifiers for processes, while signals facilitate asynchronous communication. Armed with this knowledge, you possess the tools to navigate the Unix landscape, skillfully managing processes and harnessing the power of signals.