! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
script launch by "application autostart" do not get killed when logout
Status:
RESOLVED: DUPLICATE
Product:
Xfce4-session
Component:
General

Comments

Description lsching17 2012-02-17 23:50:41 CET
I do not whether it is a bug or not.

I add several bash scripts at "application autostart" of "session startup", they  poll the computer in minute/hour and perform some maintenance stuff.

When i logout xfce, i found out that they are not killed. I checked that their parent process id are always 1 (the linux process "init") instead of xfce4-session


it is expected bahviour of xfce? acutally i expect program should get killed when logout by default, except run by "nohup" command
Comment 1 Vladimir Kudrya 2012-03-22 08:34:42 CET
I see a lot of processes started by XFCE session have parent PID 1. Both internal XFCE tools and XDG-autostarted apps.

Shouldn't they have startxfce4 or something like that as a parent process?
Comment 2 Jochen 2012-11-04 21:39:33 CET
I'm also wondering about this. I have a wallpaper changer which changes background every 5 minutes. This does not get killed at logoff and a second instance is created at new login.

In Gnome these processes were owned by gnome-session and got automatically killed. But not so with Xfce, here they are owned by init and running forever.

How can I assure that such processes get killed at logoff?
Comment 3 Vladimir Kudrya 2012-11-05 10:00:25 CET
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
--------------
Comment 4 Jochen 2012-11-05 18:49:37 CET
Thank you for that link. Works great. I now use the script in your link to get the pid of the session manager. Then I test in my Python script if it still exists, and exit if not.
Comment 5 Theo Linkspfeifer editbugs 2019-06-19 11:28:14 CEST

*** This bug has been marked as a duplicate of bug 15368 ***

Bug #8482

Reported by:
lsching17
Reported on: 2012-02-17
Last modified on: 2019-06-19

People

Assignee:
Xfce Bug Triage
CC List:
3 users

Version

Attachments

Additional information