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       These APIs are implemented as a shared library, which can be compiled
58       and linked to with the libsystemd pkg-config(1) file.
59

EXAMPLES

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

SEE ALSO

86       systemd(1), sd-bus(3), sd_bus_emit_signal(3)
87       sd_bus_message_set_destination(3)
88
89
90
91systemd 253                                       SD_BUS_MESSAGE_NEW_SIGNAL(3)
Impressum