Mate/LightDM: User logout does not stop all user processes

Hello together. I have a problem with user logout using
Ubuntu 22.04
Mate Desktop 1.26.0
LightDM 1.30.0

Whenever a user logs of not all User processes are stopped correctly, the user is still shown as logged in and their home stays mounted.
Here is a snippet result running ps aux | grep USER, roughly 60 minutes after USER logged of:

USER     3980  0.2  0.0  17656  9984 ?        Ss   14:14   0:00 /lib/systemd/systemd --user
USER     3981  0.0  0.0 197468  6108 ?        S    14:14   0:00 (sd-pam)
USER     4002  0.0  0.0  49224  7168 ?        S<sl 14:14   0:00 /usr/bin/pipewire
USER     4003  0.0  0.0  33252  7168 ?        Ssl  14:14   0:00 /usr/bin/pipewire-media-session
USER     4529  0.0  0.0 237464  6784 ?        Sl   14:14   0:00 /usr/libexec/geoclue-2.0/demos/agent
USER     5039  0.0  0.0  29052  4864 ?        Ss   14:15   0:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
USER     5194  0.2  0.0  38952 11776 ?        Ss   14:15   0:00 /snap/snapd-desktop-integration/157/usr/bin/snapd-desktop-integration
USER     5212  0.0  0.0 464136  8064 ?        Ssl  14:15   0:00 /usr/libexec/xdg-document-portal
USER     5215  0.0  0.0 236504  6272 ?        Ssl  14:15   0:00 /usr/libexec/xdg-permission-store
USER     5260  0.3  0.0 457320 59968 ?        Sl   14:15   0:00 /snap/snapd-desktop-integration/157/usr/bin/snapd-desktop-integration
USER     5265  0.0  0.0 486516 14080 ?        Ssl  14:15   0:00 /usr/libexec/xdg-desktop-portal
USER     5269  0.3  0.0 702888 60192 ?        Ssl  14:15   0:00 /usr/libexec/xdg-desktop-portal-gnome
...

This behavior is reproducible on different machines running Mate + LightDM. When switching back to gdm/GNOME3 this behavior does not occur.

For our usecase we would prefer Mate/LightDM, but to do so we need to either fix this problem or build a workaround. Any help or pointers where to look next are much appreciated.

2 Likes

Welcome, @jhorn to the community!

My questions are simply:

  • were those processes started with nohup, and therefore deliberate?
  • should nohup processes die with user session abandon (if so, impact on root-related processes)?

Workaround could be a systemd service that looks for any processes that are not linked to user logins (need to specify an exclude list for root and other services, to ensure that it could potentially trap disallowed access), and kill those processes off non-gracefully.

These processes were started by the USER login. Unless the session manager uses nohup during session creation these processes were not started with nohup. All of these should die on session end.

If you try the following (tweak it as you will), does that give you more info to identify the "offending" process?

Details on fields specified are found on bash page under the heading "STANDARD FORMAT SPECIFIERS".

----- edit 1 - modified script - added colouring for session groupings -----
----- edit 2 - modified script - added logic to determine proper max width of usernames for display -----

Script [UTIL__ReportProcessGroupingsAndProcessAge.sh]:

#!/bin/bash

####################################################################################################
###
###	Script to highlight Elapsed and CPU times for various processes
###	reporting login UID associated with processes, session ID, seat and process status
###
###	Version 3.0
###
####################################################################################################
#23456789+123456789+123456789+123456789+123456789+123456789+123456789+123456789+123456789+123456789+


tmp=$(basename "$0" ".sh").proclist

namewidth=$(cut -f1 -d":" /etc/passwd | grep -v 'snap' | sort | uniq |
	awk 'BEGIN{
		lenM=0 ;
	}{
		lenT=length( $0 ) ;
		if ( lenT > lenM ){
			lenM=lenT ;			# longest=UIDS[var] ;
		} ;
	}END{
		print lenM ;
	}'
)

ps -eo times,etimes,sess,pgrp,ppid,pid,luid,uname:${namewidth},ruser:${namewidth},ouid,lsession,seat,stat,args >"${tmp}"

head -1 "${tmp}"

tail -n +2 "${tmp}" | sort -nr -k3.1,4.0 -k1.1,2.0 | awk 'BEGIN{
	sessL=99999999 ;
	blue="\033[94;1m" ;
	green="\033[92;1m" ;
	creset="\033[0m" ;
	colour=blue ;
}{
	if( $3 != sessL ){
		if( colour == green ){
			colour=blue ;
		}else{
			colour=green ;
		} ;
		sessL=$3 ;
	} ;

	printf("%s%s%s\n", colour, $0, creset ) ;
}'