You are not logged in.

#1 Today 07:11:13

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 13,400
Website

[FIXED] The 90 second black screen after logout.

I don't often log out of my session, so this issue hasn't bothered me until recently when testing the new Wayland plugin, where I need to be able to login to and fro between X11 and Wayland systems. Every time I logged out of X11 (Wayland is OK) I got a black screen on VT7, although the other VTs worked for cli login. Switching TTY to VT2 or VT3, logging in and trying various commands seemed sometimes to work, but basically it was the default systemd timeout of 90s kicking in and bringing back the login screen.

This isn't new. I found this Lithium report from @phuturism and a more recent one from @Pinhead, but in the past we had various issues with light-locker which also caused black screen hangs, so the two issues got confused. Now we use xfce4-screensaver instead of light-locker screen locking seems OK so I was disappointed to be hit by these 90s hangs every time I logged out of X11. I'm also a bit surprised more people haven't mentioned it recently - I tried a laptop running Boron and it was just the same.

Anyway, time to get to the bottom of it I thought, and dived in with journalctl, lightdm.log and various system probes using strace, lsof... It took several days (bringing in some "help" from AI*).

Finally found that the problem was that the bl-exit logout command:

loginctl terminate-session <session-id>

sends the SIGTERM signal to all the processes running in the session. Nice. This gives them all a chance to tidy up and shut down cleanly, and also loginctl should work for all window managers etc (it works fine with labwc).

That's a problem, though, because openbox ignores SIGTERM. So after running the loginctl command openbox continues to run by itself even though the rest of the session has stopped and the screen is black. Finally after 90s systemd gets fed up waiting and sends openbox the SIGKILL signal, which it does obey, and the lightdm login screen appears. You can test this by opening eg VT2 during the black-screen hang and running 'kill -TERM <openbox's PID>', confirming nothing happens, then comparing that with 'kill -9 <openbox's PID>' and getting the login screen right away.

The fix is very simple. Openbox doesn't obey SIGTERM, but it does have a command to do a clean shutdown:

openbox --exit

This is better than just hitting it with SIGKILL because it gets a chance to clean up.

Finally, bl-exit wants to work with all window managers - not just openbox - and also there might be some processes left running after 'openbox --exit', so let's run 'loginctl terminate-session <session-id>' as well, just after the openbox command. That will catch the other well-behaved processes that do listen to SIGTERM. So in this section of bl-exit (from line #195):

        terminate-session )
            echo  -e "\n$1"
            # this line added:
            pgrep -x -u "$USER" openbox > /dev/null && { openbox --exit; sleep 1; } # openbox ignores SIGTERM sent by loginctl
            loginctl $1 $XDG_SESSION_ID
            exit $? ;;

If openbox is running it asks it to exit, and if not, things just continue as before. The 1s sleep is needed because openbox --exit  returns before all the shutting down has finished.

I don't think this is the same issue @Wasp had a while ago - loginctl wasn't working at all - but if this fix goes in bunsen-exit then it will shut down openbox for him too.

So if nobody finds any problems here I plan to add that line to bl-exit in bunsen-exit for Carbon in a few days. It wouldn't hurt to add it to Boron too.

*) This was a great example of how AI can waste your time. It gave me all kinds of commands to run, "log out and do this on another TTY..." (every logout takes 1 1/2 minutes) "Perfect! This is just what we need - now do this..." and on and on, each time claiming we were on the verge of cracking it. The final fix (above) was so simple I can't help wondering why they (I tried two different AIs) couldn't just have told me right off. Lesson learned - if AI doesn't give you a good answer pretty quickly, maybe just drop it.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

Board footer

Powered by FluxBB