Back to libut API Reference


    #include "libut/ut.h"
    int UT_signal_reg( UT_signal_cb *cb );


This function registers a callback function cb to be invoked after the process receives a signal. The callback must have this prototype:

    int (UT_signal_cb)(int signum);

The callback is not a signal handler. Rather it is invoked following receipt of a signal, during the libut event loop. The signal number is passed to the callback as its only argument. The signals that are to be caught are specified as an option to UT_init(3) which must be called prior to all other libut functions. The callback's return value isn't used.

The signal callback is invoked once per distinct signal (e.g. SIGHUP, SIGTERM, etc) that was received during the current iteration of the event loop. There is no way for the callback to tell if the signal occurred more than once in the current iteration of the event loop.

The specified callback function replaces any previously-established signal callback function. A NULL value for cb unsets any signal callback.


The return value is always 0.




Troy D. Hanson <>