-
Notifications
You must be signed in to change notification settings - Fork 7
/
dummy-client
executable file
·48 lines (40 loc) · 1.13 KB
/
dummy-client
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh
# dummy-client - Weston shell client that does nothing
# but send a signal to Xweston when Weston is ready
PROGNAME=$(basename "$0")
# Find ancestor process given its process name and a starting PID
# Return PID if found, 0 if not found
find_ancestor() {
local name pid
name=$1
pid=$2
while [ $pid -ne 0 ]; do
set -- $(ps -o comm= -o ppid= -p $pid)
[ "$1" = "$name" ] && break
pid=$2
done
echo $pid
}
error() {
echo "$PROGNAME: Error: $1" >&2
}
# Exit with error if not running under weston (perhaps we were orphaned)
weston_pid=$(find_ancestor "weston" $$)
if [ $weston_pid -eq 0 ]; then
error "not running under weston"
exit 1
fi
# Find PID of Xweston, exit with error if not found
xweston_pid=$(find_ancestor "Xweston" $weston_pid)
if [ $xweston_pid -eq 0 ]; then
error "not started by Xweston"
# Shutdown weston
kill -TERM $weston_pid
# If we exit before weston, we might be respawned. Give it some time
sleep 1
exit 1
fi
# Signal Xweston that weston is ready for connections
kill -USR2 $xweston_pid
# Execute the real desktop shell
exec /usr/lib/weston/weston-desktop-shell