GNOME Bugzilla – Bug 744736
use systemd user scope units
Last modified: 2020-04-27 20:24:12 UTC
Suggested in http://lists.freedesktop.org/archives/dbus/2015-February/016540.html : "Ideally gnome-terminal would open a user scope unit for each of its tabs."
Won't systemd user scopes also just be children of the user@1000.service, instead of being children of the actual logind session (like session-c2.scope) which has all the other "appliation" processes of the user in that session, such as the WM or firefox? With current user dbus and bug 759115 fixed, the hierarchy now has this structure (I removed most bits from systemd-cgls, and only kept the interesting bits): Control group /: └─user.slice └─user-1000.slice ├─user@1000.service │ ├─dbus.service │ │ ├─2199 /usr/bin/dbus-daemon --session --address=systemd: --nofork --n... │ │ ├─2462 /usr/lib/x86_64-linux-gnu/gconf/gconfd-2 │ │ └─3116 /usr/bin/gnome-screensaver --no-daemon │ ├─init.scope │ │ ├─2139 /lib/systemd/systemd --user │ └─gnome-terminal-server.service │ ├─2394 /usr/lib/gnome-terminal/gnome-terminal-server │ ├─2415 bash │ └─3607 systemd-cgls └─session-c2.scope ├─1120 lightdm --session-child 12 19 ├─2191 i3 ├─2322 /usr/lib/firefox/firefox I. e. processes started in a terminal (bash and systemd-cgls here) are detached from the logind session scope which has (and is supposed to) have all my other session processes such as firefox or the window manager (i3). Now, if gnome-terminal-server would start user scopes, I assume it would look something like Control group /: └─user.slice └─user-1000.slice ├─user@1000.service │ ├─dbus.service │ │ ├─2199 /usr/bin/dbus-daemon --session --address=systemd: --nofork --n... │ │ ├─2462 /usr/lib/x86_64-linux-gnu/gconf/gconfd-2 │ │ └─3116 /usr/bin/gnome-screensaver --no-daemon │ ├─init.scope │ │ ├─2139 /lib/systemd/systemd --user │ ├─gnome-terminal-tab@1.scope │ │ └─2415 bash │ ├─gnome-terminal-tab@2.scope │ │ ├─3606 bash │ │ └─3607 systemd-cgls │ └─gnome-terminal-server.service │ └─2394 /usr/lib/gnome-terminal/gnome-terminal-server └─session-c2.scope ├─1120 lightdm --session-child 12 19 ├─2191 i3 ├─2322 /usr/lib/firefox/firefox which is still not what we want, as we randomly distribute user-facing applications (which are specific to the session) across the logind session .scope and the user dbus.service. For D-Bus services like gvfs, d-conf, or dbus-daemon itself it's fine and intended to *not* put them into the logind scope, but everything else (firefox, WM, visible terminal tabs and processes started from them) are specific to the particular session only and do belong into session-c2.scope and not user@1000.service. This is also the main thing that keeps us (and I figure others) from actually using systemd --user to replace gnome-session -- There is a missing link how user .services can state that they apply to a particular logind session scope only. Once we have that, we can make gnome-terminal-server and also a "gnome-session-systemd" replacement for gnome-session use that.
> everything else (firefox, WM, visible terminal tabs and processes started from > them) are specific to the particular session only and do belong into > session-c2.scope and not user@1000.service. Rationale: All these have a $DISPLAY environment which is tied to the lifetime of the corresponding display manager/X.org instance. You can't keep firefox, xeyes or anything else to keep alive across display server boundaries, nor do you really want to. That's of course not true for CLI apps that do not actually use the $DISPLAY variable, but (1) treating them differently would be highly inconsistent (some processes survive, some not), (2) predicting which of those use $DISPLAY and which don't is not feasible (as they might spawn X clients later on as subprocesses), and (3) would not exactly help in making the whole architecture simpler and more robust.
For the record, I started a thread to discuss the more general problem: https://lists.freedesktop.org/archives/systemd-devel/2016-May/036440.html
This is fixed with vte 0.60.