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.
45
46       -EINVAL
47           The passed event loop object was invalid.
48

NOTES

50       These APIs are implemented as a shared library, which can be compiled
51       and linked to with the libsystemd pkg-config(1) file.
52

SEE ALSO

54       systemd(1), sd-event(3), sd_event_new(3), sd_event_add_signal(3)
55
56
57
58systemd 253                                        SD_EVENT_SET_SIGNAL_EXIT(3)
Impressum