1SD_EVENT_SET_SIGNAL_EXIT(3)sd_event_set_signal_exitSD_EVENT_SET_SIGNAL_EXIT(3)
2
3
4

NAME

6       sd_event_set_signal_exit - Automatically leave event loop on SIGINT and
7       SIGTERM
8

SYNOPSIS

10       #include <systemd/sd-event.h>
11
12       int sd_event_set_signal_exit(sd_event *event, int b);
13

DESCRIPTION

15       sd_event_set_signal_exit() may be used to ensure the event loop
16       terminates once a SIGINT or SIGTERM signal is received. It is a
17       convencience wrapper around invocations of sd_event_add_signal(3) for
18       both signals. The two signals are automatically added to the calling
19       thread's signal mask (if a program is multi-threaded care should be
20       taken to either invoke this function before the first thread is started
21       or to manually block the two signals process-wide first).
22
23       If the parameter b is specified as true, the event loop will terminate
24       on SIGINT and SIGTERM. If specified as false, it will no longer. When
25       this functionality is turned off the calling thread's signal mask is
26       restored to match the state before it was turned on, for the two
27       signals. By default the two signals are not handled by the event loop,
28       and Linux' default signal handling for them is in effect.
29
30       It's customary for UNIX programs to exit on either of these two
31       signals, hence it's typically a good idea to enable this functionality
32       for the main event loop of a program.
33

RETURN VALUE

35       sd_event_set_signal_exit() returns a positive non-zero value when the
36       setting was successfully changed. It returns a zero when the specified
37       setting was already in effect. On failure, it returns a negative
38       errno-style error code.
39
40   Errors
41       Returned errors may indicate the following problems:
42
43       -ECHILD
44           The event loop has been created in a different process, library or
45           module instance.
46
47       -EINVAL
48           The passed event loop object was invalid.
49

NOTES

51       Functions described here are available as a shared library, which can
52       be compiled against and linked to with the libsystemd pkg-config(1)
53       file.
54
55       The code described here uses getenv(3), which is declared to be not
56       multi-thread-safe. This means that the code calling the functions
57       described here must not call setenv(3) from a parallel thread. It is
58       recommended to only do calls to setenv() from an early phase of the
59       program when no other threads have been started.
60

SEE ALSO

62       systemd(1), sd-event(3), sd_event_new(3), sd_event_add_signal(3)
63
64
65
66systemd 254                                        SD_EVENT_SET_SIGNAL_EXIT(3)
Impressum