[go: up one dir, main page]

0% found this document useful (0 votes)
9 views2 pages

Linux_Signals_Cheat_Sheet

Linux signals are software interrupts used to notify processes of events like termination and interrupts. Common signals include SIGINT for graceful stops, SIGKILL for forceful termination, and SIGALRM for timed actions. Functions such as signal(), kill(), and raise() are used to manage and send signals within processes.

Uploaded by

sainiguharoy9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Linux_Signals_Cheat_Sheet

Linux signals are software interrupts used to notify processes of events like termination and interrupts. Common signals include SIGINT for graceful stops, SIGKILL for forceful termination, and SIGALRM for timed actions. Functions such as signal(), kill(), and raise() are used to manage and send signals within processes.

Uploaded by

sainiguharoy9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Linux Signals Cheat Sheet

What Are Signals?

Signals are software interrupts sent to a process to notify it of various events such as termination, interrupts, alarms, etc.

Common Signals and Their Uses

| Signal | Number | Description | Use Case |

|-----------|--------|------------------------------------|-------------------------------------|

| SIGINT |2 | Interrupt from keyboard (Ctrl + C) | Gracefully stop a process |

| SIGKILL | 9 | Kill signal | Forcefully terminate a process |

| SIGALRM | 14 | Alarm clock | Sent after timer set by alarm() |

| SIGUSR1 | 10 | User-defined signal 1 | Custom inter-process communication |

| SIGUSR2 | 12 | User-defined signal 2 | Custom inter-process communication |

| SIGCHLD | 17 | Child stopped or terminated | Parent knows child finished |

| SIGTERM | 15 | Termination signal | Graceful stop (default kill) |

| SIGSTOP | 19 | Stop process execution | Pause a process (can't be caught) |

| SIGHUP |1 | Hangup | Terminal closed or restart process |

When to Use Which Signal

- Use SIGALRM: When you want to trigger an action after a specific time using alarm().

- Use SIGUSR1 / SIGUSR2: For custom communication between parent-child or other processes.

- Use SIGINT: To handle Ctrl+C input from the terminal.

- Use SIGCHLD: To know when a child process ends.

- Use SIGKILL / SIGSTOP: To forcefully stop or pause a process.

Useful Functions

- signal(sig, handler): Assigns a custom function to handle a specific signal.

- kill(pid, sig): Sends a signal to another process.


Linux Signals Cheat Sheet

- raise(sig): Sends a signal to the current process.

- pause(): Suspends the process until a signal is received.

- alarm(seconds): Sends SIGALRM after given seconds.

- sigaction(): Advanced signal handling (recommended for robust apps).

- sigprocmask(): Block or unblock signals temporarily.

You might also like