Earnestly / sx

Start an xorg server
MIT License
231 stars 16 forks source link

Xorg server does not shutdown #1

Closed shizonic closed 6 years ago

shizonic commented 6 years ago

If I leave my window manager the Xorg still runs and does not shutdown. I have to switch to tty2 and kill it. How can I solve this?

Earnestly commented 6 years ago

Which window manager are you using? I can't replicate this using simple clients such as xterm and termite (libvte) or window managers like i3, spectrwm, or ratpoison.

shizonic commented 6 years ago

I am using wmfs (https://github.com/xorg62/wmfs) and I use the recommended quit function ...

Earnestly commented 6 years ago

It seems to work as expected here when using sx ./wmfs -C wmfsrc and quitting with C-M-q.

Are you perhaps using an sxrc? If so, the trouble might be there.


Edit1: Although this is triggering a segfault in wmfs when it exits, so there's very likely a bug there too.

Edit2: More oddities. It seems like the process wmfs itself doesn't respond to a SIGTERM when provided from a different tty but it will segfault when I attempt to switch back to the wmfs.

Here's a partial backtrace that I could get:

#0  0x00007f83e6b3da5b in ?? () from /usr/lib/libX11.so.6
#1  0x00007f83e6b3e295 in _XFlush () from /usr/lib/libX11.so.6
#2  0x00007f83e6b40e25 in _XGetRequest () from /usr/lib/libX11.so.6
#3  0x00007f83e6b39fcb in XSync () from /usr/lib/libX11.so.6
#4  0x00007f83e6b1bb7e in XCloseDisplay () from /usr/lib/libX11.so.6
#5  0x0000556edb17b911 in main ()

@xorg62: Any ideas what may be causing this or how to provide more useful information?

shizonic commented 6 years ago

Thanks for your reply !

Yes I Am using a sxrc file.

So you think I should report a bug to him ?

Earnestly commented 6 years ago

Yes, this does seem to be an issue with wmfs itself. However you should still be returned to the tty when wmfs crashes, at least that is what happens for me on both intel modesetting and nvidia based systems.

shizonic commented 6 years ago

Thank you! Just created an issue for him: https://github.com/xorg62/wmfs/issues/99

Earnestly commented 6 years ago

Would you mind posting your sxrc regardless?

shizonic commented 6 years ago

Of course!

#!/bin/sh

exec 1>&2 2>/dev/null

userresources="${HOME}/.Xresources"
usermodmap="${HOME}/.Xmodmap"
sysresources="/etc/X11/xinit/.Xresources"
sysmodmap="/etc/X11/xinit/.Xmodmap"
customxresources="${HOME}/.Xdefaults"

(
    # merge in defaults and keymaps
    if [ -f "${sysresources}" ]; then
        xrdb -merge "${sysresources}" &
    fi

    if [ -f "${sysmodmap}" ]; then
        xmodmap "${sysmodmap}" &
    fi

    if [ -f "${userresources}" ]; then
        xrdb -merge "${userresources}" &
    fi

    if [ -f "${usermodmap}" ]; then
        xmodmap "${usermodmap}" &
    fi

    if [ -f "${customxresources}" ]; then
        xrdb -merge "${customxresources}" &
    fi

    # disable pc speaker
    xset b off &

    # set keyboard map
    setxkbmap -layout ch -variant de &

    # swap super alt keys if we are at home
    if [ -z "${ENV_WORK}" ]; then
        setxkbmap -option altwin:swap_lalt_lwin &
    fi

    # keyboard settings - 250 ms delay and 25 cps (characters per second) repeat rate.
    xset r rate 250 25 &

    # configure touchpad
    xinput set-prop "DLL082A:01 06CB:76AF Touchpad" "libinput Tapping Enabled" 1 &
    xinput set-prop "DLL082A:01 06CB:76AF Touchpad" "libinput Tapping Drag Enabled" 1 &
    xinput set-prop "DLL082A:01 06CB:76AF Touchpad" "libinput Tapping Enabled" 1 &
    xinput set-prop "DLL082A:01 06CB:76AF Touchpad" "libinput Horizontal Scroll Enabled" 1 &
    xinput set-prop "DLL082A:01 06CB:76AF Touchpad" "libinput Disable While Typing Enabled" 1 &
    xinput set-prop "DLL082A:01 06CB:76AF Touchpad" "libinput Drag Lock Buttons" 0 &
    xinput set-prop "DLL082A:01 06CB:76AF Touchpad" "libinput Accel Speed" 1 &

    # start terminal daemon
    ${HOME}/.config/urxvt/launch &

) 1>&2 2>/dev/null

# start wm
if [ ! "x${EXEC_WM}" = "x" ]; then
    if [ ! -f "${HOME}/.config/${EXEC_WM}/launch" ]; then
        echo "error: launch file for ${EXEC_WM} does not exist"
    fi
else
    echo "error: environment variable EXEC_WM not set"
fi

exec ${HOME}/.config/${EXEC_WM}/launch
Earnestly commented 6 years ago

Hm, unfortunately I can't seem to replicate the issue after using some of the key features of your file. Since you're calling these launch scripts, can you post one of those?

I wonder if because you're spawning children such as urxvt/launch & and not cleaning them up that might be causing issues.

shizonic commented 6 years ago

Thank you ! Maybe I don't understand enough about it. So do you think if I would kill every spawning process would solve it ?

Btw.: Here is the wmfs launch script:

#!/bin/sh

pkill -x wmfs
while pgrep -x wmfs >/dev/null; do sleep 1; done

${HOME}/.config/mons/launch > ~/.local/var/log/mons.log 2>&1
(
    ${HOME}/.config/compton/launch &
    ${HOME}/.config/wmfs/scripts/status.sh > /dev/null 2>&1 &
    ${HOME}/.config/dunst/launch &
    ${HOME}/.config/Thunar/launch &
    ${HOME}/.config/xautolock/launch &
    blueman-applet &
) >/dev/null 2>&1

exec wmfs

Any other launch script looks corresponding ...

EDIT: But why does it work if I use xinit?

May the latest commit (https://github.com/xorg62/wmfs/commit/45b558475e2efc734a400573749d79e9a03a9bf4) to wmfs solve it?

Earnestly commented 6 years ago

xinit goes to greater lengths to terminate the server if it is taking awhile to end but it's not the kind of behaviour I want sx to have.

The commit you mention does solve the problem of segfaulting which is nice.

I'm not sure if it'll help your case though. The scripts are hard to follow due to all the redirections and subshell usage, but I'd suggest testing a simple case first such as sx wmfs and building it up to your current requirements to identify the problem.

shizonic commented 6 years ago

At least one problem is solved. :)

Thank you for support and help. I will do it like you said: Step by step from the ground up. :) Will also report...

shizonic commented 6 years ago

I am not sure if the latest wmfs commit (https://github.com/xorg62/wmfs/commit/2d608711d2a6562107173efab26e7aed7eed6960) fixed the issue or if it is because I changed some configs. Nevermind it works now without any issues. :) Thanks again for your work and help!

Earnestly commented 6 years ago

Ah, good to hear. I don't have to change anything \o/

shizonic commented 6 years ago

No you don't. :) Is it possible that your solution is much more performant than xinit? It feels snappier...

Earnestly commented 6 years ago

Unlikely, there probably isn't much difference compared to xinit.

shizonic commented 6 years ago

Okay. So maybe I just did imagine the better performance ;)