4 ms·
For people targeting Linux this guide is missing information about Binder and D-Bus which should be what you reach for by default for IPC.
by charcircuit 3y ago
For people targeting Linux this guide is missing information about Binder and D-Bus which should be what you reach for by default for IPC.
- zlg_codes 3y agoWhat benefits will I gain as a programmer by targeting D-Bus instead of something less complex and generally more portable? D-Bus is how XDG and Red Hat software gets onto a Linux system. Without dbus, lots of software with braindead design can stay off of your machine. PIDs, sockets, FIFOs, and other similar constructs can achieve IPC just fine.
- fulafel 3y agoDepends a lot on what you are using IPC for. It seems to me parallelizing computation for performance, isolation/sandboxing, local usage/testing of netowork-able communication, and desktop/system services signaling are the most frequent use cases. Binder and dbus both target and work well for the desktop/system services part, and badly or not at all for the other 3.
- syntheticnature 3y agoMuch like the other Beej guides, the target isn't that tightly constrained. This aims at POSIX options, and attempts to cover gotchas for cross-platform code. Not to mention that just because you're only developing for Linux doesn't guarantee you'll have Binder or D-Bus.
- charcircuit 3y ago>the target isn't that tightly constrained Yes, which is why I highlighted that it is incomplete if you are not limiting yourself to just POSIX. It's important for readers to understand the scope of what is contained in the guide as it would be easy to think this is all the IPC mechanisms Linux offers. >developing for Linux doesn't guarantee you'll have Binder or D-Bus This is technically true, but everywhere Linux is used will likely already have one of them: embedded, mobile, desktop, server, etc. For D-Bus you can even have it work in a peer to peer mode where you don't need the daemon.
- teunispeters 3y agoNeither are present in OpenWRT family, for instance. OpenWRT has developed "ubus" as kind of a dbus-alternative, but it's definitely complicated to work with effectively. Classic (Beej style) IPC though works fine.
- syntheticnature 3y agoAs someone who has done quite a bit of embedded Linux development, I assure you: neither is as common as you think.
- rtpg 3y agoDo you have any recommendations for dbus?
- kristopolous 3y agoUsing d-feet/d-spy was the most helpful thing for me in wrangling dbus along with the mantra Dbus is dumb, needy, verbose and explicit.
- charcircuit 3y agoThe systemd library for using it is worth looking at. https://0pointer.net/blog/the-new-sd-bus-api-of-systemd.html https://0pointer.net/blog/the-new-sd-bus-api-of-systemd.html
- teddyh 3y ago• <https://www.freedesktop.org/wiki/IntroductionToDBus/ https://www.freedesktop.org/wiki/IntroductionToDBus/> • <https://www.freedesktop.org/wiki/Software/dbus/ https://www.freedesktop.org/wiki/Software/dbus/> • <https://dbus.freedesktop.org/doc/dbus-specification.html https://dbus.freedesktop.org/doc/dbus-specification.html> • <https://blog.ometer.com/2007/05/17/best-d-bus-practices/ https://blog.ometer.com/2007/05/17/best-d-bus-practices/>
- justin66 3y ago> Binder and D-Bus which should be what you reach for by default for IPC. Well that’s silly. If the portable options can do it for you, use those.
- charcircuit 3y agoKeep in mind that D-Bus is built on top of Unix sockets so it's just as portable. For IPC I don't think trying to be portable is such a good thing. I think it's nice to do IPC properly for each platform you are targeting. What I personally find silly is every service rolling there own protocol making it harder for clients to use existing libraries to talk to them and making more work for themselves to get to a quality IPC solution. It usually just ends up in getting something half baked.
- justin66 3y ago> I think it's nice to do IPC properly for each platform you are targeting. There’s nothing inherently “proper” to using platform specific options, but perhaps that’s not even the issue here. It’s a beginner tutorial. A “concise overview of various IPC techniques” with examples that “should compile anywhere a good Unix compiler is available.” What you’re talking about isn’t part of the mission.
- 59nadir 3y agoI think this type of comment ought to have a bit talking about *why* you would reach for it.
- charcircuit 3y agoIt's convenient when most services on the system can all talk the same protocol. It means that services can be more easily secured because they aren't all making other own protocols from scratch. Making your program talk to various services is easier when you can use the same library and there is no need to roll your own because some service decided to make up its own custom protocol for some reason. Imagine if websites would all roll their own protocol instead of using a standard like HTTP. Having a standard IPC protocol also makes debugging easier since it makes sense for their to be real tools for seeing what's going on. Improvements to the implementations handling the protocol can make improvements throughout the whole system. There are network effects in everyone using the same protocol. If you want to step out of this ecosystem and build your own IPC protocol then you need to justify what you are gaining for the value you are giving up.
- zlg_codes 3y agoThe downside here is, should any vulnerability be found in the One True Implementation, every consumer is now vulnerable as well. Just as you shouldn't let a crop go monoculture, your software should not all be built on one or two pieces of tech. What happens when dbus is replaced? Now you have to move onto the new, broken thing, and change your code to adapt, giving control to others over your program. There are valid reasons to not just cargo cult dbus.
- dfox 3y agoIf you are targeting Linux you should probably prefer POSIX IPC to all the funky SysV weirdness involving ftok(3). The same holds for any OS that implements POSIX IPC correctly. Unfortunately, BSD derivates usually have POSIX IPC implemented as a thin wrapper in libc which makes the synchronization primitives usable either between threads or between processes and not both at once (and thus unusable for most interesting applications).