My d-bus doesn't work, or does it?

John (J5) Palmieri johnp at redhat.com
Mon Mar 7 10:37:51 PST 2005


Looks like you either have a local copy of dbus libraries compiled from
source the program you are trying to run is pointing to /usr/local.
Also you don't have a system dbus running.  

/sbin/service messagebus start

On Mon, 2005-03-07 at 11:41 -0600, Nick Gray wrote:
> Definitions out of the way, I am using Fedora Core 3 with the following
> installed by default:
> 
> dbus-glib-0.22-10
> dbus-0.22-10
> dbus-x11-0.22-10
> dbus-python-0.22-10
> dbus-devel-0.22-10
> 
> I get the following from 'ps -ef |grep dbus' 
> 
> /usr/bin/dbus-launch --exit-with-session /etc/X11/xinit/Xclients
> dbus-daemon-1 --fork --print-pid 8 --print-address 6 --session
> 
> and when I try to run the program included, I get this.
> 
> org.freedesktop.DBus.Error.FileNotFound: Failed to connect to
> socket /usr/local/var/run/dbus/system_bus_socket: No such file or
> directory
> 
> OK the first question, It looked to me like I was not running a
> system_bus, but when I try to start a system bus by hand (using the man
> page as a reference) I get another copy of the 'dbus-daemon-1 --fork --
> print-pid 8 --print-address 6 --session'. I checked to see that the
> file /usr/local/var/run/dbus/system_bus_socket' is actually in place.
> 
> Not sure where to go from here.
> 
> Here is the demo program that I copied out of LJ. I had to make a few
> syntax corrections to the public code, but they were trivial. I am
> concerned that the switch still says --session, could this mean that I
> am not really getting a system bus running?
> 
> Thanks, Nick
> 
> Code Example
> *---
> #define DBUS_API_SUBJECT_TO_CHANGE 1
> 
> #include <dbus/dbus.h>
> #include <iostream>
> 
> int main()
> {
> 	DBusError error;
> 	DBusConnection *conn;
> 	
> 	dbus_error_init(&error);
> 	conn = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
> 
> 	if (!conn)
> 	{
> 		fprintf (stderr, "%s: %s\n", error.name, error.message);
> 		return 1;
> 	}
> 	
> 	dbus_bus_acquire_service (conn, "org.pirate.parrot", 0, &error);
> 
> 	if (dbus_error_is_set (&error))
> 	{
>     	fprintf (stderr, "%s: %s\n", error.name, error.message);
>     	dbus_connection_disconnect (conn);
>     	return 1;
> 	}
> 	
> 	DBusMessage *msg;
> 	DBusMessageIter iter;
> 
> 	/* create a new message of type signal */
> 	msg = dbus_message_new_signal(
> 		"org/pirate/parrot/attr",
> 		"org.pirate.parrot.attr", "Feathers");
> 
> 	/* build the signal's payload up */
> 	dbus_message_iter_init (msg, &iter);
> 	dbus_message_iter_append_string (&iter, "Shiny");
> 	dbus_message_iter_append_string (&iter, "Well Groomed");
> 
> 	/* send the message */
> 	if (!dbus_connection_send (conn, msg, NULL))
> 	fprintf (stderr, "error sending message\n");
> 
> 	/* drop the reference count on the message */
> 	dbus_message_unref (msg);
> 
> 	/* flush the connection buffer */
> 	dbus_connection_flush (conn);
> 	
> 	if (conn)
> 	{
>         dbus_connection_disconnect (conn);
> 	}
> }
> 
> 
-- 
John (J5) Palmieri
Associate Software Engineer
Desktop Group
Red Hat, Inc.
Blog: http://martianrock.com



More information about the dbus mailing list