POSIX Signal Handling: libxfce4util Reference Manual

## 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);

#### 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. | [out][allow-none][transfer full]

#### 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` .

#### Parameters

signal | A POSIX signal id number. |

### 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

signal | A POSIX signal id number. |
handler | A callback function. | [scope call]
user_data | Arbitrary data that will be passed to `handler` . |
error | Location of a GError to store any possible errors. | [out][allow-none][transfer full]

#### 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.