C signal.h Functions

Beginner
6 min read
Updated: Nov 2026
2 tutorials
<signal.h>

Definition and Usage

<signal.h> is the C header for simple signal handling. Its two core functions are signal(), which chooses how a signal is handled, and raise(), which asks the current program to handle a signal now.

This page is the catalog for both tutorials. Start from the beginner overview if signal numbers and handlers are new, then open each function guide for syntax, return values, and three examples.

Need the model first?

Read C Signals for SIGINT, SIG_DFL, SIG_IGN, and the tiny-handler pattern.

Choose a Function by Job

I want to...Start with
Install or change a handlersignal()
Ignore a signalsignal(sig, SIG_IGN)
Restore the default actionsignal(sig, SIG_DFL)
Test a handler in the same programraise()

C signal.h Functions Index

FunctionDescriptionTutorial
raise()Send a signal to the current program.Open
signal()Install, ignore, or restore a signal disposition.Open

Key Takeaways

  • Handlers stay tiny. Prefer a volatile sig_atomic_t flag over complex work inside the handler.
  • Check SIG_ERR and raise(). Installation and delivery both have failure results.
  • Behavior varies by system. Keep examples portable and avoid assuming advanced POSIX semantics.

Frequently Asked Questions

It declares signal() and raise(), plus macros such as SIGINT, SIGTERM, SIG_DFL, SIG_IGN, and SIG_ERR.
Start with signal() to install a tiny handler, then use raise() to test it.
Set a volatile sig_atomic_t flag and return. Avoid printf, malloc, and most other library calls inside the handler.
Call signal(sig, SIG_IGN). Use SIG_DFL to restore the default action.
signal() changes the disposition. raise() asks the current program to handle a signal now.

Start with raise()

Learn how to send a signal to the current program.

raise() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful