[Xfce-bugs] [Bug 8482] script launch by "application autostart" do not get killed when logout
bugzilla-daemon at xfce.org
bugzilla-daemon at xfce.org
Mon Nov 5 10:00:25 CET 2012
https://bugzilla.xfce.org/show_bug.cgi?id=8482
--- Comment #3 from Vladimir Kudrya <vovik-wfa at bk.ru> ---
As a workaround I use a script derived from fbpanel xlogout script.
It finds session manager PID and prints it to stdout. There is also a function
to exit. You can test if session is still exist and terminate your script if it
is ended.
See info here: https://bbs.archlinux.org/viewtopic.php?pid=1179199#p1179199
script:
--------------
#!/bin/bash
getsessionpid(){
# got this from fbpanel xlogout script, refined.
# find PID of session manager process to exit when it no longer exists
# get display number
DPY=$(echo $DISPLAY | cut -d ':' -f 2)
# get X pid
XPID=$(echo $(< /tmp/.X${DPY}-lock))
# get pid of xdm (or gdm, kdm, simple xinitrc, etc). usually it's parent of X
XDMPID=$(ps -o ppid --no-headers --pid=$XPID)
# recursivly find child of xdm that was started in home dir -
# it's user's session start up script
pid_scan(){
unset XDMCHILDREN
while [ $# != 0 ]; do
XDMCHILDREN="$XDMCHILDREN $(ps --no-headers -o pid --ppid=$1)"
shift
done
for pid in $XDMCHILDREN; do
if cwd=$(ls -al /proc/$pid/cwd 2>/dev/null); then
cwd=`sed 's/.*-> //' <<< $cwd`
[ "$cwd" = "$HOME" ] && echo $pid && return
fi
done
pids=$XDMCHILDREN
[ -n "$pids" ] && pid_scan $XDMCHILDREN;
}
SESSIONPID=`pid_scan $XDMPID`
[ -z "$SESSIONPID" ] && echo "No session parent found" >&2 && false
[ -n "$SESSIONPID" ] && echo $SESSIONPID
}
exit-with-session(){
ps -eo pid | grep -qw $SESSIONPID || exit 0
}
getsessionpid
--------------
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the Xfce-bugs
mailing list