flux_signal_watcher_create(3)

SYNOPSIS

#include <flux/core.h>

typedef void (*flux_watcher_f)(flux_reactor_t *r,
                               flux_watcher_t *w,
                               int revents,
                               void *arg);

flux_watcher_t *flux_signal_watcher_create (flux_reactor_t *r,
                                            int signum,
                                            flux_watcher_f callback,
                                            void *arg);

int flux_signal_watcher_get_signum (flux_watcher_t *w);

Link with -lflux-core.

DESCRIPTION

flux_signal_watcher_create() creates a reactor watcher that monitors for receipt of signal signum.

The callback revents argument should be ignored.

When one callback is shared by multiple watchers, the signal number that triggered the event can be obtained with flux_signal_watcher_get_signum().

Signal handling can be tricky in multi-threaded programs. It is advisable to handle signals in the main thread only. For example, block signals by calling sigprocmask(2) before spawning other threads, and register signal watchers only in the main thread.

RETURN VALUE

flux_signal_watcher_create() returns a flux_watcher_t object on success. On error, NULL is returned, and errno is set appropriately.

ERRORS

ENOMEM

Out of memory.

RESOURCES

Flux: http://flux-framework.org

Flux RFC: https://flux-framework.readthedocs.io/projects/flux-rfc

Issue Tracker: https://github.com/flux-framework/flux-core/issues

libev: http://software.schmorp.de/pkg/libev.html

SEE ALSO

flux_watcher_start(3), flux_reactor_run(3)