1
0
mirror of https://github.com/frebib/dotfiles.git synced 2024-06-14 12:57:23 +00:00

systemd-run-i3: Add ExitType=cgroup to user units

systemd v250 added ExitType= which allows systemd to wait for all
processes in the cgroup to exit before terminating the unit, instead of
only the main pid. This has many uses, but for desktop applications in
particular it allows self-restarting (forking) applications to correctly
fork/restart and other background processes that may have been spawned
to continue when their forked parent inevitably exits first (like ssh
processes inside terminals).

Signed-off-by: Joe Groocock <me@frebib.net>
This commit is contained in:
Joe Groocock 2022-03-21 21:46:28 +00:00
parent ece2eb878a
commit 839d972e95
Signed by: frebib
GPG Key ID: E0B16BEACFBB6A86

View File

@ -1,5 +1,6 @@
#!/bin/bash -e
slice=app
rand=$(tr -dc 'a-f0-9' < /dev/urandom | head -c 8)
args=()
@ -16,14 +17,11 @@ do case "$opt" in
done
shift $((OPTIND-1))
if [ -z "$slice" ]; then
slice=app
fi
exec systemd-run \
--user \
--collect \
--slice="$slice" \
--unit="$slice-$1-$rand" \
--property=BindsTo=graphical-session.target \
${args[@]} -- "$@"
--property=ExitType=cgroup \
"${args[@]}" -- "$@"