1SD_BUS_MESSAGE_NEW_SIGNAL(3)sd_bus_message_new_signaSlD_BUS_MESSAGE_NEW_SIGNAL(3)
2
3
4

NAME

6       sd_bus_message_new_signal, sd_bus_message_new_signal_to - Create a
7       signal message
8

SYNOPSIS

10       #include <systemd/sd-bus.h>
11
12       int sd_bus_message_new_signal(sd_bus *bus, sd_bus_message **m,
13                                     const char *path, const char *interface,
14                                     const char *member);
15
16       int sd_bus_message_new_signal_to(sd_bus *bus, sd_bus_message **m,
17                                        const char *destination,
18                                        const char *path,
19                                        const char *interface,
20                                        const char *member);
21

DESCRIPTION

23       The sd_bus_message_new_signal() function creates a new bus message
24       object that encapsulates a D-Bus signal, and returns it in the m output
25       parameter. The signal will be sent to path path, on the interface
26       interface, member member. When this message is sent, no reply is
27       expected. See sd_bus_message_new_method_call(1) for a short description
28       of the meaning of the path, interface, and member parameters.
29
30       sd_bus_message_new_signal_to() is a shorthand for creating a new bus
31       message to a specific destination. It's behavior is similar to calling
32       sd_bus_message_new_signal() followed by calling
33       sd_bus_message_set_destination(3).
34

RETURN VALUE

36       This function returns 0 if the message object was successfully created,
37       and a negative errno-style error code otherwise.
38
39   Errors
40       Returned errors may indicate the following problems:
41
42       -EINVAL
43           The output parameter m is NULL.
44
45           The path parameter is not a valid D-Bus path ("/an/object/path"),
46           the interface parameter is not a valid D-Bus interface name
47           ("an.interface.name"), or the member parameter is not a valid D-Bus
48           member ("Name").
49
50       -ENOTCONN
51           The bus parameter bus is NULL or the bus is not connected.
52
53       -ENOMEM
54           Memory allocation failed.
55

NOTES

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

EXAMPLES

68       Example 1. Send a simple signal
69
70           /* SPDX-License-Identifier: MIT-0 */
71
72           #include <systemd/sd-bus.h>
73           #define _cleanup_(f) __attribute__((cleanup(f)))
74
75           int send_unit_files_changed(sd_bus *bus) {
76             _cleanup_(sd_bus_message_unrefp) sd_bus_message *message = NULL;
77             int r;
78
79             r = sd_bus_message_new_signal(bus, &message,
80                                           "/org/freedesktop/systemd1",
81                                           "org.freedesktop.systemd1.Manager",
82                                           "UnitFilesChanged");
83             if (r < 0)
84               return r;
85
86             return sd_bus_send(bus, message, NULL);
87           }
88
89       This function in systemd sources is used to emit the "UnitFilesChanged"
90       signal when the unit files have been changed.
91

SEE ALSO

93       systemd(1), sd-bus(3), sd_bus_emit_signal(3)
94       sd_bus_message_set_destination(3)
95
96
97
98systemd 254                                       SD_BUS_MESSAGE_NEW_SIGNAL(3)
Impressum