You are not logged in.

#1 2013-08-28 21:48:31

Mindstormscreator
Member
Registered: 2012-07-01
Posts: 186

Not all (Xorg) login session processes terminated on logout

I'm trying to create my own statusbar using Lemonboy's bar and some scripts. What I'm finding is that the scripts used to cat the panel date from the named pipe into the panel do not terminate when Xorg does (i.e. when I quit the window manager). This is problematic because the bar process continues to run even when there is no active Xorg login session, which somehow causes it to utilize 100% of my cpu until I kill it. When terminating bar and its helper scripts manually before exiting X, this does not happen.

As a simple example. let's say I have this script, nothing.sh:

#!/bin/sh
while true; do
    sleep 1
done

which I place in ~/.xinitrc before the exec command as follows:

nothing.sh &

If I start an X session, nothing.sh is running, and when I logout, it is not. However, if I run the same command from a launcher such as dmenu, when I logout from X, the process is still running in the background, even though both times it was started from within X.

Essentially, I need to know two things: what dictates which processes get killed on X logout, and how may I remedy this issue as to allow all statusbar scripts and bar itself to be terminated on logout?

Any help is appreciated.

Last edited by Mindstormscreator (2013-08-29 03:05:11)

Offline

#2 2013-08-29 01:01:52

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: Not all (Xorg) login session processes terminated on logout

When x closes all child processes are also ended (unless perhaps they were started with nohup).  But processes can be launched from withing X and given their own session ID, such as with setsid which for these purposes has a similar effect as nohup.

When you say dmenu, I'm assume you mean dmenu_run, right?  dmenu_run calls exec on the selected item, so if dmenu_run itself is a (non-nohup non-setsid) child of xinit, then it will end when xinit ends.  But this depends on how you launch dmenu_run.

You end by asking about status bar scripts and bars - but what status bar scripts, bars, and window manager(s) are you currently using, and how do you launch them.  Lets not track down an X-Y problem - if the problem is with the status script, lets see that.

EDIT: are you, by chance, using urxvtd with the -f flag without the -o flag and launching dmenu from there?  That would lead to exactly what you describe.

Last edited by Trilby (2013-08-29 01:04:22)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2013-08-29 04:32:58

Mindstormscreator
Member
Registered: 2012-07-01
Posts: 186

Re: Not all (Xorg) login session processes terminated on logout

Trilby wrote:

When you say dmenu, I'm assume you mean dmenu_run, right?  dmenu_run calls exec on the selected item, so if dmenu_run itself is a (non-nohup non-setsid) child of xinit, then it will end when xinit ends.

Yes, I mean dmenu_run.

Trilby wrote:

EDIT: are you, by chance, using urxvtd with the -f flag without the -o flag and launching dmenu from there?  That would lead to exactly what you describe.

Nope, I don't use urxvt, interesting guess though.

Trilby wrote:

You end by asking about status bar scripts and bars - but what status bar scripts, bars, and window manager(s) are you currently using, and how do you launch them.  Lets not track down an X-Y problem - if the problem is with the status script, lets see that.

Alright, I'll describe the basic setup I'm trying to achieve. I'm using bspwm, which outputs its status to $PANEL_FIFO, which is /dev/shm/panel.fifo

My full .xinitrc:

xrdb ~/.Xresources
xset +fp /usr/share/fonts/local 
xset +fp /home/alex/.fonts
xset +fp /usr/share/fonts/artwiz-fonts
xset +fp /usr/share/fonts/misc 
xset fp rehash 

xsetroot -cursor_name left_ptr &

xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape' &
hsetroot -fill /home/alex/pic/desktop-backgrounds/arch_watery.png &
#unclutter -grab -noevents -root &
#compton -cCb &

# Start a D-Bus session
source /etc/X11/xinit/xinitrc.d/30-dbus
# Start GNOME Keyring
eval $(/usr/bin/gnome-keyring-daemon --start --components=gpg,pkcs11,secrets,ssh)
# You probably need to do this too:
export GNOME_KEYRING_CONTROL GNOME_KEYRING_PID GPG_AGENT_INFO SSH_AUTH_SOCK

thunar --daemon &
kupfer --no-splash &

sxhkd &

[ -e "$PANEL_FIFO" ] && rm "$PANEL_FIFO"
mkfifo -m 600 "$PANEL_FIFO"

panel &
exec bspwm -c /home/alex/.config/bspwm/autostart -s "$PANEL_FIFO" -p W

That panel script:

#!/bin/sh

flavor=${1:-bar}

case "$flavor" in
	bar)
		cat "$PANEL_FIFO" | panel_bar | bar &
		;;
esac

clock -sf 'C%a %H:%M' > "$PANEL_FIFO" &

This setup is minimal at the moment for testing.

The panel_bar script:

#!/bin/sh

while read -r line; do
	case $line in
		W*)
			wminfo="\\l\\u7$line\\ur"
			;;
		C*)
			clock="\\c$line"
			;;
	esac

	printf "%s\n" "$wminfo $clock"
done

Now, with this setup, I can exit X and all of the scripts and bar are killed. However, the problem arises when I want to restart the bar while in X. If I kill off the cat, bar, panel, and panel_bar processes, and then run "panel" from a terminal or dmenu_run and THEN exit X, bar is not killed. This holds true even if dmenu_run is launched from a keyboard shortcut bound with sxhkd.

I hope this is more clear. I would like to have the bar and related scripts killed on logout, even after reloading them.

Last edited by Mindstormscreator (2013-08-29 18:35:13)

Offline

Board footer

Powered by FluxBB