Preventing proliferation of dbus-daemon instances
I was reading on the Internet, someone reporting hundreds of
dbus-daemon instances, and impacting on system performance. I was
googling this topic, as was having a problem with some AppImages and
Flatpaks not working with dbus.
Guitar is an AppImage that does work with dbus. As they are setup to
run as a unique user, a session dbus-daemon has to be launched for each
user. Problem is, after quiting Guitar, the daemons are still running:
# ps | grep dbus
2082 root 0:00 {rc.services_ipc} /bin/ash /etc/rc.d/rc.services_ipc bluetoothhw:dbus bluetooth:bluealsa
3954 messageb 0:01 /usr/bin/dbus-daemon --system
4302 root 0:00 dbus-launch --autolaunch=9e2323c574f908750e4a3dbd642226f0 --binary-syntax --close-stderr
4303 root 0:00 /usr/bin/dbus-daemon --syslog-only --fork --print-pid 5 --print-address 7 --session
26521 root 0:00 /usr/bin/dbus-daemon --syslog --fork --print-pid 5 --print-address 7 --session
32497 guitar 0:00 dbus-launch --autolaunch 9e2323c574f908750e4a3dbd642226f0 --binary-syntax --close-stderr
32498 guitar 0:00 /usr/bin/dbus-daemon --syslog-only --fork --print-pid 5 --print-address 7 --session
This is the problem that people are reporting; instances starting
then never terminating. I haven't studied the topic enough to determine
why some people are getting a huge number of instances.
DeltaChat is an AppImage that reports unable to connect to the dbus. I
seem to have found a solution so it does connect, and also the
dbus-daemon instance terminates after the app has exited. This is
/usr/bin/deltachat.bin:
#!/bin/sh
export $(dbus-launch)
/mnt/wkg/appimage/deltachat/deltachat-1.34.4.AppImage
kill $DBUS_SESSION_BUS_PID
Previously, had a symlink /usr/bin/deltachat.bin to the AppImage, now
it is a script. The script runs as the user "deltachat" and the first
line in the script provides the information that the AppImage needs to
access dbus. The last line kills the dbus-daemon instance.
After starting DeltaChat:
# ps | grep dbus
2082 root 0:00 {rc.services_ipc} /bin/ash /etc/rc.d/rc.services_ipc bluetoothhw:dbus bluetooth:bluealsa
2223 deltacha 0:00 /usr/bin/dbus-daemon --syslog --fork --print-pid 5 --print-address 7 --session
3954 messageb 0:01 /usr/bin/dbus-daemon --system
4302 root 0:00 dbus-launch --autolaunch=9e2323c574f908750e4a3dbd642226f0 --binary-syntax --close-stderr
4303 root 0:00 /usr/bin/dbus-daemon --syslog-only --fork --print-pid 5 --print-address 7 --session
26521 root 0:00 /usr/bin/dbus-daemon --syslog --fork --print-pid 5 --print-address 7 --session
32497 guitar 0:00 dbus-launch --autolaunch 9e2323c574f908750e4a3dbd642226f0 --binary-syntax --close-stderr
32498 guitar 0:00 /usr/bin/dbus-daemon --syslog-only --fork --print-pid 5 --print-address 7 --session
Then after quiting DeltaChat, that highlighted line is gone.
This is the fix I remembered last night, then forgot in the morning.
The memory came back later. Most importantly, start 'deltachat' in a
terminal, it no longer reports unable to connect to dbus.
Both the AppImage Installer (appi) and the Flatpak Installer (Flapi) have this fix.
Tags: easy