How to get rid of orphan dbus-daemon processes?
This issue doesn't seem to be related to any specific distro or desktop environment.
When I try to open a file manager as root calling, for instance, sudo thunar
the units at left of the file manager appear with no label (plus some undesirable units like pts, shm, proc, sys, etc). Compare the left window (normal user) vs the right window (sudo):
If I call sudo dbus-launch --exit-with-session thunar
it loads just fine (just like as normal user), however after closing the application a dbus-daemon
instance keeps running forever (as seen at the bottom in the screenshot above).
If I call sudo dbus-run-session -- thunar
it loads just fine and no orphan process is left behind after the application is closed, so it looks the right way of doing it. However if I want to open a file instead of an application AFAIK I need to call xdg-open
, but when combined with dbus-run-session
it doesn't work at all -- the only way is calling sudo dbus-launch --exit-with-session xdg-open /home/test.txt
, which brings me to the original issue (i.e. orphan dbus-daemon processes).
Is there a good solution for this?
I reproduced this issue on Slackware Live Xfce (December 2021), Ubuntu 20.04 and Porteus nightly.