From 1abf7879cd9c4be290caf3ed776cb1ec65d6a1a4 Mon Sep 17 00:00:00 2001 From: Brot der Bot Date: Fri, 1 May 2026 15:02:39 +0200 Subject: [PATCH] detach long-running background processes from autostart service cgroup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit KDE Plasma runs each autostart .desktop entry as a systemd user unit. systemd tracks service liveness by cgroup membership, not just the main PID. Any process forked inside the service — even via setsid or & — stays in the service's cgroup and keeps app-logon_script.sh@autostart in active (running) state indefinitely after logon_script.sh exits. mount_ecrypt_home.sh: wrap the gocryptfs mount call with systemd-run --user --scope --unit=gocryptfs-home The FUSE daemon that gocryptfs forks now lives in its own transient scope cgroup. Exit-code propagation is unchanged because systemd-run --scope returns the main process's exit code. 0050_nextcloud_desktopclient/user_run.sh: replace /usr/bin/setsid ... & with systemd-run --user --scope --unit=nextcloud-client ... & setsid creates a new session but does not move the process out of the cgroup; systemd-run --scope does. Co-Authored-By: Claude Sonnet 4.6 --- client_software/0050_nextcloud_desktopclient/user_run.sh | 2 +- system_setup/mount_ecrypt_home.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/client_software/0050_nextcloud_desktopclient/user_run.sh b/client_software/0050_nextcloud_desktopclient/user_run.sh index 8657bf7..9803d81 100755 --- a/client_software/0050_nextcloud_desktopclient/user_run.sh +++ b/client_software/0050_nextcloud_desktopclient/user_run.sh @@ -151,7 +151,7 @@ done #fi # Now start Nextcloud echo "Starting Nextcloud Client in Background" -/usr/bin/setsid ${BASECMD} >${TEMPDIR}/nc_desktop_client.log 2>&1 & +systemd-run --user --scope --unit=nextcloud-client ${BASECMD} >${TEMPDIR}/nc_desktop_client.log 2>&1 & sleep 2 echo "Done Setup of Nextcloud." exit 0 diff --git a/system_setup/mount_ecrypt_home.sh b/system_setup/mount_ecrypt_home.sh index 59f43fb..5d3ddd4 100755 --- a/system_setup/mount_ecrypt_home.sh +++ b/system_setup/mount_ecrypt_home.sh @@ -93,7 +93,8 @@ if [ ! -d "${DECRYPTEDDATADIR}" ] || [ ! -f "${HOME}/.config/gocryptfs/gocryptfs mkdir -p ${ENCRYPTEDDATADIR} ${DECRYPTEDDATADIR} ${HOME}/.config/gocryptfs gocryptfs -init -allow_other -passfile /var/tmp/IPAVAULTKEY.txt -config ${HOME}/.config/gocryptfs/gocryptfs.conf ${ENCRYPTEDDATADIR} >/dev/null fi -gocryptfs -noprealloc -allow_other -passfile /var/tmp/IPAVAULTKEY.txt -config ${HOME}/.config/gocryptfs/gocryptfs.conf ${ENCRYPTEDDATADIR} ${DECRYPTEDDATADIR} >/dev/null +systemd-run --user --scope --unit=gocryptfs-home \ + gocryptfs -noprealloc -allow_other -passfile /var/tmp/IPAVAULTKEY.txt -config ${HOME}/.config/gocryptfs/gocryptfs.conf ${ENCRYPTEDDATADIR} ${DECRYPTEDDATADIR} >/dev/null RETVAL=$? rm /var/tmp/IPAVAULTKEY.txt cd ${EXECDIR}