summary refs log tree commit diff
path: root/os/etc/s6-rc/src/desktop-session-running/find-marker-proc
diff options
context:
space:
mode:
Diffstat (limited to 'os/etc/s6-rc/src/desktop-session-running/find-marker-proc')
-rwxr-xr-xos/etc/s6-rc/src/desktop-session-running/find-marker-proc15
1 files changed, 15 insertions, 0 deletions
diff --git a/os/etc/s6-rc/src/desktop-session-running/find-marker-proc b/os/etc/s6-rc/src/desktop-session-running/find-marker-proc
new file mode 100755
index 0000000..4f39eec
--- /dev/null
+++ b/os/etc/s6-rc/src/desktop-session-running/find-marker-proc
@@ -0,0 +1,15 @@
+#!/bin/sh
+# find first process with marker=true envvar set
+set -eu
+uid="${1:?}"
+done=
+while true; do
+	for pid in $(pgrep -u ${uid}); do
+		if grep -q 'marker=true' /proc/${pid}/environ 2>/dev/null; then
+			printf "%s" "$pid"
+			done=1
+			break
+		fi
+	done
+	[ -n "$done" ] && break
+done