www.delorie.com/gnu/docs/glibc/libc_487.html   search  
 
Buy the book!


The GNU C Library

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

24.4 Defining Signal Handlers

This section describes how to write a signal handler function that can be established with the signal or sigaction functions.

A signal handler is just a function that you compile together with the rest of the program. Instead of directly invoking the function, you use signal or sigaction to tell the operating system to call it when a signal arrives. This is known as establishing the handler. See section 24.3 Specifying Signal Actions.

There are two basic strategies you can use in signal handler functions:

You need to take special care in writing handler functions because they can be called asynchronously. That is, a handler might be called at any point in the program, unpredictably. If two signals arrive during a very short interval, one handler can run within another. This section describes what your handler should do, and what you should avoid.

24.4.1 Signal Handlers that Return  Handlers that return normally, and what this means.
24.4.2 Handlers That Terminate the Process  How handler functions terminate a program.
24.4.3 Nonlocal Control Transfer in Handlers  Nonlocal transfer of control out of a signal handler.
24.4.4 Signals Arriving While a Handler Runs  What happens when signals arrive while the handler is already occupied.
24.4.5 Signals Close Together Merge into One  When a second signal arrives before the first is handled.
24.4.6 Signal Handling and Nonreentrant Functions  Do not call any functions unless you know they are reentrant with respect to signals.
24.4.7 Atomic Data Access and Signal Handling  A single handler can run in the middle of reading or writing a single object.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003