A handler to receive notification about POSIX signals.

Synopsis

Declared in <folly/io/async/AsyncSignalHandler.h>

class AsyncSignalHandler;

Description

AsyncSignalHandler allows code to process signals from within a EventBase loop.

Standard signal handlers interrupt execution of the main thread, and are run while the main thread is paused. As a result, great care must be taken to avoid race conditions if the signal handler has to access or modify any data used by the main thread.

AsyncSignalHandler solves this problem by running the AsyncSignalHandler callback in normal thread of execution, as a EventBase callback.

AsyncSignalHandler may only be used in a single thread. It will only process signals received by the thread where the AsyncSignalHandler is registered. It is the user's responsibility to ensure that signals are delivered to the desired thread in multi‐threaded programs.

Member Functions

Name

Description

AsyncSignalHandler [constructor]

Create a new AsyncSignalHandler.

~AsyncSignalHandler [destructor] [virtual]

Destroy the AsyncSignalHandler, unregistering any remaining signals.

attachEventBase

Attach this AsyncSignalHandler to an EventBase.

detachEventBase

Detach this AsyncSignalHandler from its EventBase.

getEventBase

Get the EventBase used by this AsyncSignalHandler.

registerSignalHandler

Register to receive callbacks about the specified signal.

signalReceived [virtual]

signalReceived() will called to indicate that the specified signal has been received.

unregisterSignalHandler

Unregister for callbacks about the specified signal.

Derived Classes

Name

Description

CallbackAsyncSignalHandler

Derived template class that allows forwarding of a callback to be invoked in the overridden signalReceived().

Created with MrDocs