#include #include #include #include #include #include #include #include static DBusConnection *conn; int main(int argc, char* argv[]) { DBusError err; dbus_error_init(&err); DBusConnection *conn = dbus_bus_get(DBUS_BUS_SESSION, &err); if (NULL == conn) exit(1); int ret = dbus_bus_request_name(conn, "test.server", DBUS_NAME_FLAG_REPLACE_EXISTING , &err); if (dbus_error_is_set(&err)) exit(1); for (;;) { DBusMessage *msg = dbus_message_new_signal("/test/server", "test.server.Event", "Broadcast"); if (NULL == msg) exit(1); const char *item1 = "item1 of array1"; const char *item2 = "item2 of array1"; const char *item3 = "item3 of array2"; const char *item4 = "item4 of array2"; const char *array[] = { &item1, &item2 }; const char *array2[] = { &item3, &item4 }; int fd1 = open("/dev/null", O_RDONLY); if (fd1 < 0) exit(1); int fd2 = open("/dev/null", O_RDONLY); if (fd2 < 0) exit(1); /* * leak memory and unix fd */ if (!dbus_message_append_args(msg, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &array, 2, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &array2, 2, DBUS_TYPE_UNIX_FD, &fd1, DBUS_TYPE_UNIX_FD, &fd2, DBUS_TYPE_INVALID)) exit(1); if (!dbus_connection_send(conn, msg, NULL)) exit(1); dbus_connection_flush(conn); dbus_message_unref(msg); sleep(1); } return 0; }