dbus
are launched remotely (via ssh
, LSF
, or a similar tool), dbus
processes keep running even after the main process is closed, blocking the remote session and preven...For interactive use, make sure to launch dbus-run-session before the shell. For instance, add this to .bashrc:
if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
exec dbus-run-session -- bash
echo "D-Bus per-session daemon address is: $DBUS_SESSION_BUS_ADDRESS"
fi
Write bash_logout script which will be in charge of killing remaining dbus-* programs for the session, assuming it's the last bash
# ~/.bash_logout
# Check if we are the "parent" shell in a ssh session
[ "$(cat /proc/$PPID/comm)" == "sshd" ] || return
cgroup=$(awk -F ':' '$2 == "name=systemd" { print $3 }' /proc/self/cgroup)
[ -n "$cgroup" ] || return
# Search for "dbus-[daemon|launch]" programs running for this session
for pid in $(cat /sys/fs/cgroup/systemd/$cgroup/tasks 2>/dev/null); do
comm=$(cat /proc/$pid/comm 2>/dev/null)
case "$comm" in
|dbus-launch)
dbus-daemonecho "Killing '$comm' (PID $pid) ..."
kill $pid
;;
esac
done