On Wed 17 Nov 2021 at 22:39:21 (+0100), Arkadiusz Dabrowski wrote: > I have a problem with unison sync termination when it is started from > .xsessionrc. > It works flawlessly but when I log out it is orphaned and not terminated. > I start it like this: > nice -n18 ionice -c2 -n7 unison unison_profile &>/dev/null & > Once started the parent is x-session-manager and they the same process > group.
I think this is because you're starting it in the wrong file. Everything in .xsessionrc should complete immediately. Use it to set parameters and things like that. > What can I do to terminate the process with x-session? Start all your X clients and programs in .xsession. They should all be backgrounded with &, as shown in man xinit. There's an example at about line 78 (buster version) on that page. You'll see there that they start the Window Manager last. This has disadvantages, in that you can't tell programs like xterm where to map their windows if the WM hasn't yet started. This is solved by exec'ing the WM early in .xsession, and waiting on its PID at the end. If and when you close the WM, wait terminates and you fall out of the end of .xsession, and X terminates. That way, all these background processes get destroyed, and the same is true if you are in the habit of using Ctrl-Alt-Backspace to kill X rather than neatly closing the WM. Briefly: # ~/.xsession contents # very early stuff # [ … ] if [ -x /usr/bin/fvwm ]; then exec /usr/bin/fvwm & Wmpid=$! else printf '%s\n' "Error - no window manager found" fi # now start your clients and programs, all backgrounded with & # [ … ] # at the end of the file is one foreground program: # wait for the window manager in the background to die wait $Wmpid # end-of-file Cheers, David.