## POSIX Signal Handling

POSIX Signal Handling — a callback system for handling POSIX signals safely

## Functions

void | (*XfcePosixSignalHandler) ()
gboolean | xfce_posix_signal_handler_init ()
void | xfce_posix_signal_handler_restore_handler ()
gboolean | xfce_posix_signal_handler_set_handler ()
void | xfce_posix_signal_handler_shutdown ()

## Includes

    #include <libxfce4util/libxfce4util.h>

## Description

Due to reentrancy issues, there is a restricted set of functions/syscalls that are allowed to be performed inside a POSIX signal handler. In general, it's safer to defer any signal-related processing until after the signal handler has run. The functionality in this module automatically handles this, and allows you to set a handler function (with optional user data) for any signal.

## Functions

### XfcePosixSignalHandler ()

    void
    (*XfcePosixSignalHandler) (gint signal,
                               gpointer user_data);

A function signature to use for POSIX signal handler functions.

#### Parameters

signal | The signal that was caught. |
user_data | The `user_data` parameter passed when the handler was registered. |

### xfce_posix_signal_handler_init ()

    gboolean
    xfce_posix_signal_handler_init (GError **error);

Initializes the POSIX signal handler system. Must be called before setting any POSIX signal handlers.

#### Parameters

error | Location of a GError to store any possible errors. |

#### Returns

`TRUE` on success, `FALSE` on failure, in which case `error` will be set.

### xfce_posix_signal_handler_restore_handler ()

    void
    xfce_posix_signal_handler_restore_handler
                                   (gint signal);

Restores the default handler for `signal` .

### xfce_posix_signal_handler_set_handler ()

    gboolean
    xfce_posix_signal_handler_set_handler (gint signal,
                                           XfcePosixSignalHandler handler,
                                           gpointer user_data,
                                           GError **error);

Sets `handler` to be called whenever `signal` is caught by the application. The `user_data` parameter will be passed as an argument to `handler` .

#### Parameters

handler | A callback function. |
user_data | Arbitrary data that will be passed to `handler` . |
error | Location of a GError to store any possible errors. |

#### Returns

`TRUE` on success, `FALSE` otherwise, in which case `error` will be set.

### xfce_posix_signal_handler_shutdown ()

    void
    xfce_posix_signal_handler_shutdown (void);

Frees all memory associated with the POSIX signal handling system and restores all default signal handlers.

## Types and Values