Crypto++ 8.4 Free C++ class library of cryptographic schemes

Public Member Functions | List of all members
SignalHandler< S, O > Struct Template Reference

Signal handler for Linux and Unix compatibles. More...

## Public Member Functions
| SignalHandler (SignalHandlerFn pfn=NULL, int flags=0)
| Construct a signal handler. More...

## Detailed Description

### template<int S, bool O = false>
struct SignalHandler< S, O >

Signal handler for Linux and Unix compatibles.

Template Parameters

  S | Signal number
  O | Flag indicating if an existing handler should be overwritten

SignalHandler() can be used to install a signal handler with the signature `void handler_fn(int)`. If `SignalHandlerFn` is not `NULL`, then the sigaction is set to the function and the sigaction flags is set to the flags. If `SignalHandlerFn` is `NULL`, then a default handler is installed using sigaction flags set to 0. The default handler only returns from the call.

Upon destruction the previous signal handler is restored if the former signal handler was replaced.

On Cygwin systems using Newlib, you should define `_XOPEN_SOURCE=700` or `_GNU_SOURCE`; or use `-std=gnu++03`, `-std=gnu++11`, or similar. If you compile with `-std=c++03`, `-std=c++11` or similar, then define `_XOPEN_SOURCE=700`.

Warning
  Do not use SignalHandler in a code block that uses `setjmp` or `longjmp` because the destructor may not run.

Since
  Crypto++ 5.6.5

See also
  NullSignalHandler, SignalHandlerFn, CRYPTOPP_ASSERT, DebugTrapHandler

Definition at line 58 of file ossig.h.

## Constructor & Destructor Documentation

## ◆ SignalHandler()

template<int S, bool O = false>

SignalHandler< S, O >::SignalHandler | ( | SignalHandlerFn | pfn = `NULL`,
|  | int | flags = `0`
| ) |  |
| inline

Construct a signal handler.

Parameters

  pfn | Pointer to a signal handler function
  flags | Flags to use with the signal handler

SignalHandler() installs a signal handler with the signature `void handler_fn(int)`. If `SignalHandlerFn` is not `NULL`, then the sigaction is set to the function and the sigaction flags is set to the flags. If `SignalHandlerFn` is `NULL`, then a default handler is installed using sigaction flags set to 0. The default handler only returns from the call.

Upon destruction the previous signal handler is restored if the former signal handler was overwritten.

On Cygwin systems using Newlib, you should define `_XOPEN_SOURCE=700` or `_GNU_SOURCE`; or use `-std=gnu++03`, `-std=gnu++11`, or similar. If you compile with `-std=c++03`, `-std=c++11` or similar, then define `_XOPEN_SOURCE=700`.

Warning
  Do not use SignalHandler in a code block that uses `setjmp` or `longjmp` because the destructor may not run. `setjmp` is why cpu.cpp does not use SignalHandler during CPU feature testing.

Since
  Crypto++ 5.6.5

Definition at line 78 of file ossig.h.

The documentation for this struct was generated from the following file:

- ossig.h