4 ms·
Can anybody explain to me what dbus is for, and why I sometimes have to start applications using "dbus-launch" because otherwise they can't connect to dbus. Or
by amelius 3y ago
Can anybody explain to me what dbus is for, and why I sometimes have to start applications using "dbus-launch" because otherwise they can't connect to dbus. Or why sometimes when I login on other systems using "ssh -CY" I cannot even start applications like eog (eye of gnome) because dbus is in the way, but somehow mysteriously they DO start when I run them with "strace -f"?
Seems to me that Linux systems are starting to see the downsides of a microservices approach.
Edit: thanks for all the replies, yes, I get that dbus is for sending messages between applications, but what is wrong with e.g. UNIX domain sockets?
- ladendroid 3y ago"D-Bus provides a software-bus abstraction that gathers all the communications between a group of processes over a single shared virtual channel. Processes connected to a bus do not know how it is internally implemented, but D-Bus specification guarantees that all processes connected to the bus can communicate with each other through it." https://en.wikipedia.org/wiki/D-Bus https://en.wikipedia.org/wiki/D-Bus
- JohnFen 3y agodbus is a mechanism that allows different processes to communicate with each other. I think (but I'm not sure) that it's primarily used by Gnome and KDE.
- throwway120385 3y agoDBus is yet another message bus, but this time for a few desktop applications. Made famous by BlueZ's requirement of DBus and by it being the only Linux userspace thing that made it into Android before they completely rewrote the userspace stack for the phones. A ton of "desktop linux" components will attempt to use DBus for inter-process communication because it's easier than a lot of the alternatives.
- zh3 3y agoEh, some of us would wonder what the easier alteratives are?
- qbasic_forever 3y agoUnix domain sockets or FIFOs could be an alternative, but you'd have to do all kinds of complexity to support pub/sub style many to many communication over them (which is what dbus effectively does for you).
- amelius 3y agoIt depends if you are a fan of a centralized server vs decentralized communication. Anyway, all the complexities of using sockets/FIFOs could be hidden inside libraries.
- deleted 3y ago[deleted]
- SAI_Peregrinus 3y agoOnce you hide the complexities of using sockets you just end up with some sort of message bus that each application connects to and registers an ID with... which is essentially what dbus is.
- amelius 3y agoI specifically said libraries (as opposed to a centralized service).
- qbasic_forever 3y agoDbus doesn't have anything to do with systemd FYI. It's a communication bus for processes to talk to each other through structured RPC messages.
- amelius 3y agoFrom the article: > udev and dbus are forced dependencies.
- qbasic_forever 3y agoYes systemd can use dbus, but plenty of non-systemd systems use and used dbus.
- zh3 3y agoNot true (although maybe in the systemd world?). udev just populates /dev dynamically (rather than having to create all the /dev/ entries manually/via scripts). Even udev is optional (upon upon a time, adding a new device involved knowing the right 'mknod' invocation in order to be able to connect to it - udev sort-of solves that).
- SAI_Peregrinus 3y agoDbus isn't a systemd project any more than a libc is a systemd project. Systemd just requires it as a dependency. It's a freedesktop project.
- amelius 3y agoIt's from the same microservices ecosystem, and it was mentioned in the article. That's why I brought it up.
- zh3 3y agodbus is a sort-of standardised way for applications to communicate; generally used so that a service can make itself available to clients (e.g. battery status, bluetooth devices, plenty of other things that I don't happen to use). Generally I only start it if an application won't work without it. Biggest issues for me (personally) is it's linux-specific and (unless I'm missing something) limited to the current host); otherwise it's client-agnostic sockets FTW.
- toast0 3y ago> Edit: thanks for all the replies, yes, I get that dbus is for sending messages between applications, but what is wrong with e.g. UNIX domain sockets? I think the reason for dbus is that all of these processes want to talk to all the other ones, and they need to rendezvous somewhere. You probably don't want to open a unix socket for every 'topic' you want to respond to, and anyway if there's multiple programs interested in the topic, how do you make sure they all get all of the messages, if they all listen to the socket, only one gets the message. For desktopy things, you could communicate through the X server, but some of the things you might want to communicate with are system daemons, not X applications. I don't know if Wayland provides a way for multiple clients to communicate? OTOH, dbus doesn't transit over the network, so eog on a remote host can't communicate with your desktop environment, so that's kind of a pain. Yet another capability lost overtime. grumblegrumble*
- amelius 3y ago> if there's multiple programs interested in the topic, how do you make sure they all get all of the messages, if they all listen to the socket, only one gets the message. Well, you could listen on a socket for subscribers ... (Basically a decentralized approach vs a centralized approach) > OTOH, dbus doesn't transit over the network, so eog on a remote host can't communicate with your desktop environment, so that's kind of a pain. Yes, and what I find mysterious is that dbus was conceived by the freedesktop.org project. How could they have missed this important requirement?
- deleted 3y ago[deleted]
- qbasic_forever 3y agoDistributed RPC, i.e. dbus over the network, is an incredibly complex and still basically unsolved problem. To really do it right and guarantee correctness across systems (which may be in different states of working or failed!) you need a perfect message queue with exactly once delivery... but in practice implementing that is incredibly storage intensive (you'd have to store every message forever). You're basically asking for something as complex and difficult to run as kafka--it's not as simple as just send dbus messages over a network socket.