mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-02 20:21:59 -05:00
fix(desktop): run Plasma, its helpers and the apps it opens outside Android's child-process count (#3599)
This commit is contained in:
1 parent
34fff40b56
commit
4ab9635ceb
9 files changed
+281
-20
No files matched your search
@@ -481,5 +481,69 @@
|
||||
<service android:name=".runtime.GuestWorker61" android:exported="false" android:process=":g61" />
|
||||
<service android:name=".runtime.GuestWorker62" android:exported="false" android:process=":g62" />
|
||||
<service android:name=".runtime.GuestWorker63" android:exported="false" android:process=":g63" />
|
||||
<service android:name=".runtime.GuestWorker64" android:exported="false" android:process=":g64" />
|
||||
<service android:name=".runtime.GuestWorker65" android:exported="false" android:process=":g65" />
|
||||
<service android:name=".runtime.GuestWorker66" android:exported="false" android:process=":g66" />
|
||||
<service android:name=".runtime.GuestWorker67" android:exported="false" android:process=":g67" />
|
||||
<service android:name=".runtime.GuestWorker68" android:exported="false" android:process=":g68" />
|
||||
<service android:name=".runtime.GuestWorker69" android:exported="false" android:process=":g69" />
|
||||
<service android:name=".runtime.GuestWorker70" android:exported="false" android:process=":g70" />
|
||||
<service android:name=".runtime.GuestWorker71" android:exported="false" android:process=":g71" />
|
||||
<service android:name=".runtime.GuestWorker72" android:exported="false" android:process=":g72" />
|
||||
<service android:name=".runtime.GuestWorker73" android:exported="false" android:process=":g73" />
|
||||
<service android:name=".runtime.GuestWorker74" android:exported="false" android:process=":g74" />
|
||||
<service android:name=".runtime.GuestWorker75" android:exported="false" android:process=":g75" />
|
||||
<service android:name=".runtime.GuestWorker76" android:exported="false" android:process=":g76" />
|
||||
<service android:name=".runtime.GuestWorker77" android:exported="false" android:process=":g77" />
|
||||
<service android:name=".runtime.GuestWorker78" android:exported="false" android:process=":g78" />
|
||||
<service android:name=".runtime.GuestWorker79" android:exported="false" android:process=":g79" />
|
||||
<service android:name=".runtime.GuestWorker80" android:exported="false" android:process=":g80" />
|
||||
<service android:name=".runtime.GuestWorker81" android:exported="false" android:process=":g81" />
|
||||
<service android:name=".runtime.GuestWorker82" android:exported="false" android:process=":g82" />
|
||||
<service android:name=".runtime.GuestWorker83" android:exported="false" android:process=":g83" />
|
||||
<service android:name=".runtime.GuestWorker84" android:exported="false" android:process=":g84" />
|
||||
<service android:name=".runtime.GuestWorker85" android:exported="false" android:process=":g85" />
|
||||
<service android:name=".runtime.GuestWorker86" android:exported="false" android:process=":g86" />
|
||||
<service android:name=".runtime.GuestWorker87" android:exported="false" android:process=":g87" />
|
||||
<service android:name=".runtime.GuestWorker88" android:exported="false" android:process=":g88" />
|
||||
<service android:name=".runtime.GuestWorker89" android:exported="false" android:process=":g89" />
|
||||
<service android:name=".runtime.GuestWorker90" android:exported="false" android:process=":g90" />
|
||||
<service android:name=".runtime.GuestWorker91" android:exported="false" android:process=":g91" />
|
||||
<service android:name=".runtime.GuestWorker92" android:exported="false" android:process=":g92" />
|
||||
<service android:name=".runtime.GuestWorker93" android:exported="false" android:process=":g93" />
|
||||
<service android:name=".runtime.GuestWorker94" android:exported="false" android:process=":g94" />
|
||||
<service android:name=".runtime.GuestWorker95" android:exported="false" android:process=":g95" />
|
||||
<service android:name=".runtime.GuestWorker96" android:exported="false" android:process=":g96" />
|
||||
<service android:name=".runtime.GuestWorker97" android:exported="false" android:process=":g97" />
|
||||
<service android:name=".runtime.GuestWorker98" android:exported="false" android:process=":g98" />
|
||||
<service android:name=".runtime.GuestWorker99" android:exported="false" android:process=":g99" />
|
||||
<service android:name=".runtime.GuestWorker100" android:exported="false" android:process=":g100" />
|
||||
<service android:name=".runtime.GuestWorker101" android:exported="false" android:process=":g101" />
|
||||
<service android:name=".runtime.GuestWorker102" android:exported="false" android:process=":g102" />
|
||||
<service android:name=".runtime.GuestWorker103" android:exported="false" android:process=":g103" />
|
||||
<service android:name=".runtime.GuestWorker104" android:exported="false" android:process=":g104" />
|
||||
<service android:name=".runtime.GuestWorker105" android:exported="false" android:process=":g105" />
|
||||
<service android:name=".runtime.GuestWorker106" android:exported="false" android:process=":g106" />
|
||||
<service android:name=".runtime.GuestWorker107" android:exported="false" android:process=":g107" />
|
||||
<service android:name=".runtime.GuestWorker108" android:exported="false" android:process=":g108" />
|
||||
<service android:name=".runtime.GuestWorker109" android:exported="false" android:process=":g109" />
|
||||
<service android:name=".runtime.GuestWorker110" android:exported="false" android:process=":g110" />
|
||||
<service android:name=".runtime.GuestWorker111" android:exported="false" android:process=":g111" />
|
||||
<service android:name=".runtime.GuestWorker112" android:exported="false" android:process=":g112" />
|
||||
<service android:name=".runtime.GuestWorker113" android:exported="false" android:process=":g113" />
|
||||
<service android:name=".runtime.GuestWorker114" android:exported="false" android:process=":g114" />
|
||||
<service android:name=".runtime.GuestWorker115" android:exported="false" android:process=":g115" />
|
||||
<service android:name=".runtime.GuestWorker116" android:exported="false" android:process=":g116" />
|
||||
<service android:name=".runtime.GuestWorker117" android:exported="false" android:process=":g117" />
|
||||
<service android:name=".runtime.GuestWorker118" android:exported="false" android:process=":g118" />
|
||||
<service android:name=".runtime.GuestWorker119" android:exported="false" android:process=":g119" />
|
||||
<service android:name=".runtime.GuestWorker120" android:exported="false" android:process=":g120" />
|
||||
<service android:name=".runtime.GuestWorker121" android:exported="false" android:process=":g121" />
|
||||
<service android:name=".runtime.GuestWorker122" android:exported="false" android:process=":g122" />
|
||||
<service android:name=".runtime.GuestWorker123" android:exported="false" android:process=":g123" />
|
||||
<service android:name=".runtime.GuestWorker124" android:exported="false" android:process=":g124" />
|
||||
<service android:name=".runtime.GuestWorker125" android:exported="false" android:process=":g125" />
|
||||
<service android:name=".runtime.GuestWorker126" android:exported="false" android:process=":g126" />
|
||||
<service android:name=".runtime.GuestWorker127" android:exported="false" android:process=":g127" />
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -224,6 +224,70 @@ class GuestWorker60 : GuestWorker()
|
||||
class GuestWorker61 : GuestWorker()
|
||||
class GuestWorker62 : GuestWorker()
|
||||
class GuestWorker63 : GuestWorker()
|
||||
class GuestWorker64 : GuestWorker()
|
||||
class GuestWorker65 : GuestWorker()
|
||||
class GuestWorker66 : GuestWorker()
|
||||
class GuestWorker67 : GuestWorker()
|
||||
class GuestWorker68 : GuestWorker()
|
||||
class GuestWorker69 : GuestWorker()
|
||||
class GuestWorker70 : GuestWorker()
|
||||
class GuestWorker71 : GuestWorker()
|
||||
class GuestWorker72 : GuestWorker()
|
||||
class GuestWorker73 : GuestWorker()
|
||||
class GuestWorker74 : GuestWorker()
|
||||
class GuestWorker75 : GuestWorker()
|
||||
class GuestWorker76 : GuestWorker()
|
||||
class GuestWorker77 : GuestWorker()
|
||||
class GuestWorker78 : GuestWorker()
|
||||
class GuestWorker79 : GuestWorker()
|
||||
class GuestWorker80 : GuestWorker()
|
||||
class GuestWorker81 : GuestWorker()
|
||||
class GuestWorker82 : GuestWorker()
|
||||
class GuestWorker83 : GuestWorker()
|
||||
class GuestWorker84 : GuestWorker()
|
||||
class GuestWorker85 : GuestWorker()
|
||||
class GuestWorker86 : GuestWorker()
|
||||
class GuestWorker87 : GuestWorker()
|
||||
class GuestWorker88 : GuestWorker()
|
||||
class GuestWorker89 : GuestWorker()
|
||||
class GuestWorker90 : GuestWorker()
|
||||
class GuestWorker91 : GuestWorker()
|
||||
class GuestWorker92 : GuestWorker()
|
||||
class GuestWorker93 : GuestWorker()
|
||||
class GuestWorker94 : GuestWorker()
|
||||
class GuestWorker95 : GuestWorker()
|
||||
class GuestWorker96 : GuestWorker()
|
||||
class GuestWorker97 : GuestWorker()
|
||||
class GuestWorker98 : GuestWorker()
|
||||
class GuestWorker99 : GuestWorker()
|
||||
class GuestWorker100 : GuestWorker()
|
||||
class GuestWorker101 : GuestWorker()
|
||||
class GuestWorker102 : GuestWorker()
|
||||
class GuestWorker103 : GuestWorker()
|
||||
class GuestWorker104 : GuestWorker()
|
||||
class GuestWorker105 : GuestWorker()
|
||||
class GuestWorker106 : GuestWorker()
|
||||
class GuestWorker107 : GuestWorker()
|
||||
class GuestWorker108 : GuestWorker()
|
||||
class GuestWorker109 : GuestWorker()
|
||||
class GuestWorker110 : GuestWorker()
|
||||
class GuestWorker111 : GuestWorker()
|
||||
class GuestWorker112 : GuestWorker()
|
||||
class GuestWorker113 : GuestWorker()
|
||||
class GuestWorker114 : GuestWorker()
|
||||
class GuestWorker115 : GuestWorker()
|
||||
class GuestWorker116 : GuestWorker()
|
||||
class GuestWorker117 : GuestWorker()
|
||||
class GuestWorker118 : GuestWorker()
|
||||
class GuestWorker119 : GuestWorker()
|
||||
class GuestWorker120 : GuestWorker()
|
||||
class GuestWorker121 : GuestWorker()
|
||||
class GuestWorker122 : GuestWorker()
|
||||
class GuestWorker123 : GuestWorker()
|
||||
class GuestWorker124 : GuestWorker()
|
||||
class GuestWorker125 : GuestWorker()
|
||||
class GuestWorker126 : GuestWorker()
|
||||
class GuestWorker127 : GuestWorker()
|
||||
|
||||
/** The pool of [GuestWorker] processes, and the socket guests ask it through (`droiddeck-spawn`). */
|
||||
object GuestWorkers {
|
||||
@@ -250,7 +314,28 @@ object GuestWorkers {
|
||||
GuestWorker54::class.java, GuestWorker55::class.java, GuestWorker56::class.java,
|
||||
GuestWorker57::class.java, GuestWorker58::class.java, GuestWorker59::class.java,
|
||||
GuestWorker60::class.java, GuestWorker61::class.java, GuestWorker62::class.java,
|
||||
GuestWorker63::class.java,
|
||||
GuestWorker63::class.java, GuestWorker64::class.java, GuestWorker65::class.java,
|
||||
GuestWorker66::class.java, GuestWorker67::class.java, GuestWorker68::class.java,
|
||||
GuestWorker69::class.java, GuestWorker70::class.java, GuestWorker71::class.java,
|
||||
GuestWorker72::class.java, GuestWorker73::class.java, GuestWorker74::class.java,
|
||||
GuestWorker75::class.java, GuestWorker76::class.java, GuestWorker77::class.java,
|
||||
GuestWorker78::class.java, GuestWorker79::class.java, GuestWorker80::class.java,
|
||||
GuestWorker81::class.java, GuestWorker82::class.java, GuestWorker83::class.java,
|
||||
GuestWorker84::class.java, GuestWorker85::class.java, GuestWorker86::class.java,
|
||||
GuestWorker87::class.java, GuestWorker88::class.java, GuestWorker89::class.java,
|
||||
GuestWorker90::class.java, GuestWorker91::class.java, GuestWorker92::class.java,
|
||||
GuestWorker93::class.java, GuestWorker94::class.java, GuestWorker95::class.java,
|
||||
GuestWorker96::class.java, GuestWorker97::class.java, GuestWorker98::class.java,
|
||||
GuestWorker99::class.java, GuestWorker100::class.java, GuestWorker101::class.java,
|
||||
GuestWorker102::class.java, GuestWorker103::class.java, GuestWorker104::class.java,
|
||||
GuestWorker105::class.java, GuestWorker106::class.java, GuestWorker107::class.java,
|
||||
GuestWorker108::class.java, GuestWorker109::class.java, GuestWorker110::class.java,
|
||||
GuestWorker111::class.java, GuestWorker112::class.java, GuestWorker113::class.java,
|
||||
GuestWorker114::class.java, GuestWorker115::class.java, GuestWorker116::class.java,
|
||||
GuestWorker117::class.java, GuestWorker118::class.java, GuestWorker119::class.java,
|
||||
GuestWorker120::class.java, GuestWorker121::class.java, GuestWorker122::class.java,
|
||||
GuestWorker123::class.java, GuestWorker124::class.java, GuestWorker125::class.java,
|
||||
GuestWorker126::class.java, GuestWorker127::class.java,
|
||||
)
|
||||
|
||||
private class Slot(val index: Int) {
|
||||
|
||||
@@ -172,7 +172,7 @@ there.
|
||||
|
||||
### B. Exec-in-place workers for long-lived processes
|
||||
|
||||
Declare a pool of `android:process` services (`:g0`…`:g95`). Each long-lived program runs as the
|
||||
Declare a pool of `android:process` services (`:g0`…`:g127`). Each long-lived program runs as the
|
||||
main process of one worker (Gap 2): full app privileges, direct GPU, normal signals and `/proc`
|
||||
(same uid and SELinux domain), and the app hears its exit through binder death. Costs and limits:
|
||||
|
||||
@@ -262,8 +262,29 @@ vfork-safe (Python's subprocess execs under `vfork`). Details that mattered:
|
||||
session (KDE Plasma, 17–19 counted at rest), a Konsole running 40 `sleep 600 &` jobs peaked at
|
||||
61 counted and lost 27 processes to Android's limit (Konsole, D-Bus, the portal) before this, and
|
||||
at 20 with no kills after. Still counted, and not handed off: a terminal's foreground jobs (a
|
||||
`make -j` and its compilers), the D-Bus daemon's activation helpers (forks that never exec) and
|
||||
the desktop's own programs started by KDE's launchers.
|
||||
`make -j` and its compilers) and the D-Bus daemon's activation helpers (forks that never exec).
|
||||
- **The desktop.** Plasma's own programs are listed (`startplasma-wayland`, `plasma_session`,
|
||||
KWin, `kded6`, `ksmserver`, `plasmashell`, PowerDevil, KDE Connect, the KIO workers, the D-Bus
|
||||
activated portal, dconf and activity manager) along with DroidDeck's desktop helpers. Discover's
|
||||
update notifier, GeoClue's demo agent and the global-menu proxy are off in the user's Autostart.
|
||||
A program a desktop launcher starts (`DD_HANDOFF_LAUNCHERS`: Plasma's shell, KRunner, Dolphin)
|
||||
goes to a worker when it is a plain fork and exec: in the launcher's process group and session,
|
||||
with no controlling terminal. Those launchers are Qt programs, which wait with `waitpid()` once
|
||||
the hook has taken their pidfds away. A terminal's shell (its own session and terminal) stays.
|
||||
Firefox runs with fission off, at most two web content processes and no crash helper. The
|
||||
desktop and its apps use about 80 workers with Steam and a game running, hence 128.
|
||||
|
||||
Counted children on the Thor (main: the session as #3338 and #3594 left it):
|
||||
|
||||
| | main | this |
|
||||
|---|---|---|
|
||||
| desktop at rest | 30 | 0 |
|
||||
| Dolphin, Konsole, Firefox, Kate and System Settings open | not measured (49 on a Pocket FIT without Firefox, the terminal running 40 jobs) | 7 |
|
||||
| those, the desktop's Steam client and Bully running | not measured | 20 (30 with 64 workers: Wine's services were refused one) |
|
||||
|
||||
With Bully running, six scans forced with the stock limit of 32 killed nothing. What stays
|
||||
counted then: Steam's client and launch chain (10), Firefox's helpers (6), Konsole's shell,
|
||||
Proton's script and `wineserver`.
|
||||
|
||||
Default list: the portals, at-spi, `python3`, PipeWire, WirePlumber, Decky's PluginLoader, the log's
|
||||
`gnudd`, `xprop -spy`, the web helper's renderers, `wine`, `wine-preloader`, `wineserver`.
|
||||
|
||||
@@ -9,7 +9,7 @@ export MOZ_ENABLE_WAYLAND=1 MOZ_USE_XINPUT2=1
|
||||
export SHELL=/bin/bash
|
||||
export MOZ_DISABLE_CONTENT_SANDBOX=1 MOZ_DISABLE_GMP_SANDBOX=1 MOZ_DISABLE_RDD_SANDBOX=1
|
||||
export MOZ_DISABLE_SOCKET_PROCESS_SANDBOX=1 MOZ_DISABLE_UTILITY_SANDBOX=1
|
||||
export MOZ_SHM_NO_SEALS=1
|
||||
export MOZ_SHM_NO_SEALS=1 MOZ_CRASHREPORTER_DISABLE=1
|
||||
export QTWEBENGINE_DISABLE_SANDBOX=1
|
||||
export KWIN_COMPOSE=Q QT_QUICK_BACKEND=software LIBGL_ALWAYS_SOFTWARE=1 GALLIUM_DRIVER=llvmpipe
|
||||
export KWIN_USE_OVERLAYS=0
|
||||
@@ -142,11 +142,10 @@ Exec=konsole -e /usr/local/bin/droiddeck-steam-x64
|
||||
Icon=steam
|
||||
Categories=System;
|
||||
ENTRY
|
||||
python3 /usr/local/bin/droiddeck-pad-defaults 2>&1 | sed 's/^/[pads] /'
|
||||
( while sleep 30; do python3 /usr/local/bin/droiddeck-pad-defaults 2>&1 | sed 's/^/[pads] /'; done ) &
|
||||
python3 /usr/local/bin/droiddeck-pad-defaults --every 30 &
|
||||
python3 /usr/local/bin/droiddeck-desktop-gpu 2>&1 | sed 's/^/[gpu] /'
|
||||
/usr/local/bin/droiddeck-desktop-window-rules 2>&1 | sed 's/^/[rules] /'
|
||||
( python3 /usr/local/bin/droiddeck-library-perms 2>&1 | sed 's/^/[perms] /' ) &
|
||||
python3 /usr/local/bin/droiddeck-library-perms 2>&1 &
|
||||
mkdir -p /usr/local/share/applications
|
||||
cat > /usr/local/share/applications/droiddeck-ime.desktop <<'ENTRY'
|
||||
[Desktop Entry]
|
||||
@@ -175,6 +174,15 @@ fi
|
||||
if command -v flatpak >/dev/null 2>&1 && [ ! -d /var/lib/pacman ]; then
|
||||
FLATPAK_BWRAP=/usr/local/bin/droiddeck-bwrap flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo >/dev/null 2>&1 &
|
||||
fi
|
||||
# Android counts the desktop's programs against an app's limit of 32. Off unless the user turns them
|
||||
# back on in Autostart: Discover's update notifier (the packages follow DroidDeck's releases, and it
|
||||
# keeps PackageKit running as root), GeoClue's demo agent (nothing asks for a location) and the
|
||||
# global-menu proxy (the panel has no global menu).
|
||||
mkdir -p "$HOME/.config/autostart"
|
||||
for entry in org.kde.discover.notifier geoclue-demo-agent gmenudbusmenuproxy; do
|
||||
[ -e "$HOME/.config/autostart/$entry.desktop" ] ||
|
||||
printf '[Desktop Entry]\nType=Application\nName=%s\nHidden=true\n' "$entry" > "$HOME/.config/autostart/$entry.desktop"
|
||||
done
|
||||
skel_done=$HOME/.local/share/droiddeck/skel-copied
|
||||
if [ -d /etc/skel ] && [ ! -e "$skel_done" ]; then
|
||||
cp -rn /etc/skel/. "$HOME/" 2>/dev/null
|
||||
|
||||
@@ -9,3 +9,11 @@ pref("datareporting.policy.dataSubmissionEnabled", false);
|
||||
pref("browser.aboutwelcome.enabled", false);
|
||||
pref("browser.startup.homepage", "about:blank");
|
||||
pref("layout.css.devPixelsPerPx", "1.25");
|
||||
// Android counts each of Firefox's processes against the app's limit of 32: one web content process
|
||||
// per two tabs' worth of sites rather than one per site, none started ahead, and extensions and
|
||||
// about: pages in the processes that already exist.
|
||||
pref("fission.autostart", false);
|
||||
pref("dom.ipc.processCount", 2);
|
||||
pref("dom.ipc.processPrelaunch.enabled", false);
|
||||
pref("browser.tabs.remote.separatePrivilegedContentProcess", false);
|
||||
pref("extensions.webextensions.remote", false);
|
||||
@@ -1,6 +1,8 @@
|
||||
#!/usr/bin/python3
|
||||
import glob
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
HOME = os.environ.get("HOME", "/root")
|
||||
CONFIG = os.environ.get("XDG_CONFIG_HOME", os.path.join(HOME, ".config"))
|
||||
@@ -1048,8 +1050,19 @@ def switch_emulators():
|
||||
print(f"droiddeck-pad-defaults: {name}: Player 1 on the controller ({cfg})")
|
||||
|
||||
|
||||
for step in (rpcs3, duckstation, pcsx2, armsx2, dolphin, cemu, melonds, ppsspp, retroarch, switch_emulators):
|
||||
try:
|
||||
step()
|
||||
except Exception as e:
|
||||
print(f"droiddeck-pad-defaults: {step.__name__}: {e}")
|
||||
def run_all():
|
||||
for step in (rpcs3, duckstation, pcsx2, armsx2, dolphin, cemu, melonds, ppsspp, retroarch, switch_emulators):
|
||||
try:
|
||||
step()
|
||||
except Exception as e:
|
||||
print(f"droiddeck-pad-defaults: {step.__name__}: {e}", flush=True)
|
||||
|
||||
|
||||
# --every SECONDS: again at that interval, for emulators set up while the desktop runs. One process
|
||||
# for the whole desktop session rather than a shell loop starting a new one each time.
|
||||
sys.stdout.reconfigure(line_buffering=True)
|
||||
run_all()
|
||||
if len(sys.argv) == 3 and sys.argv[1] == "--every":
|
||||
while True:
|
||||
time.sleep(float(sys.argv[2]))
|
||||
run_all()
|
||||
@@ -63,9 +63,11 @@ dd_job() {
|
||||
# window's app by walking its process's parents) or its utility processes (the client only accepts
|
||||
# its transport from its own children).
|
||||
if [ "${DD_SPAWN_DAEMONS:-1}" = 1 ] && [ -n "${DD_SPAWN:-}" ]; then
|
||||
export DD_HANDOFF=${DD_HANDOFF-xdg-desktop-portal:xdg-permission-store:xdg-desktop-portal-gtk:at-spi-bus-launcher:at-spi2-registryd:plasma_waitforname:bash+dd-job:droiddeck-log-writer:gamescope:gamescopereaper:droiddeck-session+steam:Xwayland:dbus-launch:droiddeck-agent:droiddeck-launcher-cores:droiddeck-pace-cores:droiddeck-documents:droiddeck-steam-games+watch:droiddeck-steam-compat:dbus-daemon+--nofork:proton:pipewire:wireplumber:PluginLoader:PluginLoader.real:xprop+-spy:gnudd:steamwebhelper+--type=renderer:wine:wine-preloader:wine64:wine64-preloader:wineserver}
|
||||
export DD_HANDOFF=${DD_HANDOFF-xdg-desktop-portal:xdg-permission-store:xdg-desktop-portal-gtk:at-spi-bus-launcher:at-spi2-registryd:plasma_waitforname:bash+dd-job:droiddeck-log-writer:gamescope:gamescopereaper:droiddeck-session+steam:Xwayland:dbus-launch:droiddeck-agent:droiddeck-launcher-cores:droiddeck-pace-cores:droiddeck-documents:droiddeck-steam-games+watch:droiddeck-steam-compat:dbus-daemon+--nofork:proton:pipewire:wireplumber:PluginLoader:PluginLoader.real:xprop+-spy:gnudd:steamwebhelper+--type=renderer:wine:wine-preloader:wine64:wine64-preloader:wineserver:droiddeck-login1:droiddeck-snapd:droiddeck-polkitd:droiddeck-root+/usr/libexec/packagekitd:droiddeck-desktop-clipboard:droiddeck-ime:droiddeck-pad-defaults+--every:droiddeck-library-perms:droiddeck-clipboard:dbus-run-session:startplasma-wayland:plasma_session:kwin_wayland_wrapper:kwin_wayland:kded6:ksmserver:kglobalacceld:plasmashell:krunner:org_kde_powerdevil:xembedsniproxy:kaccess:xsettingsd:kdeconnectd:kunifiedpush-distributor:kactivitymanagerd:xdg-desktop-portal-kde:dconf-service:polkit-kde-authentication-agent-1:plasma-welcome:kioworker}
|
||||
# The programs these start for the user (an app from the panel, a file opened in Dolphin)
|
||||
export DD_HANDOFF_LAUNCHERS=${DD_HANDOFF_LAUNCHERS-plasmashell:krunner:dolphin}
|
||||
else
|
||||
unset DD_HANDOFF
|
||||
unset DD_HANDOFF DD_HANDOFF_LAUNCHERS
|
||||
fi
|
||||
steam_setup_failed() {
|
||||
echo "== steam: the Steam client could not be set up (status $1)"
|
||||
|
||||
@@ -1274,6 +1274,30 @@ static int ddh_job_control_job(void) {
|
||||
return ddh_waiter(parent) && (pid_t)syscall(SYS_getpgid, 0) != (pid_t)syscall(SYS_getpgid, parent);
|
||||
}
|
||||
|
||||
// Whether this is a program a desktop launcher starts for the user (DD_HANDOFF_LAUNCHERS names the
|
||||
// launchers: Plasma's shell, KRunner, Dolphin): a plain fork and exec, still in the launcher's process
|
||||
// group and session, with no controlling terminal. Those launchers are Qt programs, which wait with
|
||||
// waitpid() once they have no pidfds (privileged.c), so the program's exit reaches them. A child the
|
||||
// launcher set up as a terminal's (a session and a terminal of its own) stays its own child.
|
||||
static int ddh_launched(const char *filename, char *const argv[], char *const envp[]) {
|
||||
const char *list = ddh_env(envp, "DD_HANDOFF_LAUNCHERS");
|
||||
if (!list || !*list || ddh_exec_stub(filename) || ddh_pressure_keeps(filename, argv)) return 0;
|
||||
pid_t parent = (pid_t)syscall(SYS_getppid);
|
||||
char path[48], name[32];
|
||||
snprintf(path, sizeof(path), "/proc/%d/comm", (int)parent);
|
||||
if (ddh_read_proc(path, name, sizeof(name)) <= 0) return 0;
|
||||
name[strcspn(name, "\n")] = 0;
|
||||
if (!ddh_listed(list, name, NULL)) return 0;
|
||||
if ((pid_t)syscall(SYS_getpgid, 0) != (pid_t)syscall(SYS_getpgid, parent) ||
|
||||
(pid_t)syscall(SYS_getsid, 0) != (pid_t)syscall(SYS_getsid, parent))
|
||||
return 0;
|
||||
// /dev/tty opens only for a process with a controlling terminal
|
||||
int tty = (int)call_orig_syscall(SYS_openat, (unsigned long)AT_FDCWD, (unsigned long)"/dev/tty",
|
||||
O_RDONLY | O_NOCTTY | O_NONBLOCK | O_CLOEXEC, 0, 0, 0);
|
||||
if (tty >= 0) syscall(SYS_close, tty);
|
||||
return tty < 0;
|
||||
}
|
||||
|
||||
static int ddh_pressed(const char *filename, char *const argv[], char *const envp[]) {
|
||||
if (ddh_exec_stub(filename) || ddh_pressure_keeps(filename, argv) || !ddh_waiter((pid_t)syscall(SYS_getppid))) return 0;
|
||||
// Not a job in the foreground of its controlling terminal: a handed-off program has none (the
|
||||
@@ -1364,7 +1388,8 @@ static void ddh_try_as(const char *filename, char *const argv[], char *const env
|
||||
ddh_debug(envp, "a job-control job:", filename);
|
||||
return;
|
||||
}
|
||||
if (!ddh_program_listed(list, match_file, match_argv) && !ddh_pressed(match_file, match_argv, envp)) {
|
||||
if (!ddh_program_listed(list, match_file, match_argv) && !ddh_launched(match_file, match_argv, envp) &&
|
||||
!ddh_pressed(match_file, match_argv, envp)) {
|
||||
ddh_debug(envp, "not listed:", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1480,7 +1480,7 @@ class NativeHookHandoffTest(unittest.TestCase):
|
||||
raise RuntimeError("workers that may still run: %s" % failed)
|
||||
|
||||
def run_parent(self, *argv, handoff="target", hook=True, reports=True, pressure=None, as_shell=False, terminal=False,
|
||||
delay=0, extra_env=None):
|
||||
delay=0, extra_env=None, parent_name=None):
|
||||
name = "dd-handoff-test-%d-%s-%s-%d" % (os.getpid(), self.id().rsplit(".", 1)[-1], handoff, hook)
|
||||
spawner = FakeSpawner(name, self.prefix or [], self.root, reports, delay)
|
||||
spawner.start()
|
||||
@@ -1496,9 +1496,9 @@ class NativeHookHandoffTest(unittest.TestCase):
|
||||
hook_env["QEMU_LD_PREFIX"] = self.prefix[self.prefix.index("-L") + 1]
|
||||
env = {k: v for k, v in os.environ.items() if k not in hook_env}
|
||||
prefix, parent = list(self.prefix or []), str(self.parent)
|
||||
if as_shell:
|
||||
# the hook tells a shell's child by its parent's name (qemu-user takes the program's)
|
||||
shell = Path(self.tmp.name) / ("shell-%s" % self.id().rsplit(".", 1)[-1]) / "bash"
|
||||
if as_shell or parent_name:
|
||||
# the hook tells a shell's or a launcher's child by its parent's name (qemu-user takes the program's)
|
||||
shell = Path(self.tmp.name) / ("shell-%s" % self.id().rsplit(".", 1)[-1]) / (parent_name or "bash")
|
||||
shell.parent.mkdir(exist_ok=True)
|
||||
shutil.copy(parent, shell)
|
||||
parent = str(shell)
|
||||
@@ -1707,6 +1707,41 @@ class NativeHookHandoffTest(unittest.TestCase):
|
||||
self.assertEqual([], requests)
|
||||
self.assertEqual(self.child_status, result.get("exit"), out.stdout)
|
||||
|
||||
def run_launcher(self, *argv, parent_name="plasmashell", **kwargs):
|
||||
return self.run_parent(*argv, handoff="other", pressure=1000, parent_name=parent_name,
|
||||
extra_env={"DD_HANDOFF_LAUNCHERS": "plasmashell:krunner"}, **kwargs)
|
||||
|
||||
def test_a_program_a_desktop_launcher_starts_is_handed_off(self):
|
||||
# an app from Plasma's panel: unlisted, far from the limit, still its own app process
|
||||
result, requests, out = self.run_launcher("wait", "7")
|
||||
self.assertEqual(1, len(requests), out.stderr)
|
||||
self.assertEqual(["target", "7"], requests[0]["argv"])
|
||||
self.assertEqual("7", result.get("exit"), out.stdout)
|
||||
|
||||
def test_a_child_of_a_program_not_named_a_launcher_is_not(self):
|
||||
result, requests, out = self.run_launcher("wait", "3", parent_name="konsole")
|
||||
self.assertEqual([], requests, out.stderr)
|
||||
self.assertEqual(self.child_status, result.get("exit"), out.stdout)
|
||||
|
||||
def test_a_launchers_child_in_a_process_group_of_its_own_is_not(self):
|
||||
result, requests, out = self.run_launcher("group", "4")
|
||||
self.assertEqual([], requests, out.stderr)
|
||||
self.assertEqual("4" if self.child_status == "3" else "127", result.get("exit"), out.stdout)
|
||||
|
||||
def test_a_launchers_child_on_a_terminal_is_not(self):
|
||||
# a terminal's shell, set up by its launcher (Konsole's part in Dolphin): the terminal is its own
|
||||
result, requests, out = self.run_launcher("wait", "3", terminal=True)
|
||||
self.assertEqual([], requests, out.stderr)
|
||||
self.assertEqual(self.child_status, result.get("exit"), out.stdout)
|
||||
|
||||
def test_the_steam_client_a_launcher_starts_is_not(self):
|
||||
steam = self.root / "bin/steam"
|
||||
if not steam.exists():
|
||||
shutil.copy(self.root / "bin/target", steam)
|
||||
result, requests, out = self.run_launcher("wait", "3", "/bin/steam")
|
||||
self.assertEqual([], requests, out.stderr)
|
||||
self.assertEqual(self.child_status, result.get("exit"), out.stdout)
|
||||
|
||||
def test_near_the_limit_a_child_of_another_program_is_not(self):
|
||||
result, requests, out = self.run_parent("wait", "3", handoff="other", pressure=0)
|
||||
self.assertEqual([], requests)
|
||||
|
||||
Reference in new issue
Block a user