tvrzna / emptty

Dead simple CLI Display Manager on TTY
MIT License
696 stars 26 forks source link

When shutting down computer, emptty halts for a minute or two and produces ~/core. #96

Closed amano-kenji closed 1 year ago

amano-kenji commented 1 year ago

The file size of ~/core is about 51 megabytes.

$ gdb emptty core
GNU gdb (Gentoo 13.2 vanilla) 13.2
....
Reading symbols from emptty...

warning: Can't open file /dev/shm/wlroots-EGAnPO (deleted) during file-backed mapping note processing

warning: core file may not match specified executable file.
[New LWP 4426]
[New LWP 4473]
[New LWP 4474]
Core was generated by `Xwayland :0 -rootless -core -terminate 10 -listenfd 27 -listenfd 29 -displayfd'.
Program terminated with signal SIGABRT, Aborted.
#0  0x00007f034f3ed9fc in ?? ()
[Current thread is 1 (LWP 4426)]
amano-kenji commented 1 year ago

This seems to be xwayland issue.

amano-kenji commented 1 year ago

Reopening because this issue started after upgrading emptty to 0.11.0

tvrzna commented 1 year ago

Can you, please, provide more info about your configuration? Because changes between v0.10.0 and v0.11.0 are mostly superficial. Couldn't it be related to #92, where was a change in OpenRC service requested?

edit: Does it happens also in case of running emptty as root?

amano-kenji commented 1 year ago
UID        PID  PPID  C STIME TTY      STAT   TIME CMD
root      3280 19914  0 10:08 tty7     Ssl+   0:00 /usr/bin/emptty -d

emptty is already running as root. I think the change to openrc init file could be the cause of the issue. I will investigate.

amano-kenji commented 1 year ago

Adding

EMPTTY_TERMTIMEOUT=${EMPTTY_TERMTIMEOUT:-"TERM/60/KILL/15"}
retry="${EMPTTY_TERMTIMEOUT}"

to openrc init script merely shed a light on the real issue.

If ~/.config/emptty is

#!/bin/bash
Selection=true

xrdb -merge ~/.Xresources

. /etc/profile
. ~/.env

dinit &

"$@"

dinitctl shutdown

emptty fails to kill ~/.config/emptty sway. If ~/.config/emptty is

#!/bin/bash
Selection=true

xrdb -merge ~/.Xresources

. /etc/profile
. ~/.env

exec "$@"

emptty can kill ~/.config/emptty sway immediately. Thus, I need a way to properly shut down ~/.config/emptty without losing the part that handles dinit.

tvrzna commented 1 year ago

Seems like any script after starting a desktop (even with Xorg) causes the same issue (e.g. logout from Openbox). Maybe some kind of user exit script would do the thing, if I can't find another solution.

amano-kenji commented 1 year ago

If ~/.config/emptty is a shell script, then the last statement should be exec "$@". Otherwise, emptty fails to kill ~/.config/emptty.

amano-kenji commented 1 year ago

I see two options.

tvrzna commented 1 year ago

Currently there is already DISPLAY_STOP_SCRIPT, however it's started out of user's session as root. So I don't think this would help you. Custom script run by keyboard shortcuts wouldn't handle service termination, so it looks like user exit script is the only way. Also this script should have some short timeout, before it is also terminated (to avoid longer than usual situations).

amano-kenji commented 1 year ago

These scripts seem to be able to reboot and power off my computer inside a sway session in response to sway keyboard shortcuts.

my-sway-reboot

#!/bin/sh
dinitctl shutdown
sudo my-reboot

my-sway-poweroff

#!/bin/sh
dinitctl shutdown
sudo my-poweroff

sudo my-reboot and sudo my-poweroff are executed without password.

Because ~/.config/emptty looks like

#!/bin/bash
Selection=true

xrdb -merge ~/.Xresources

. /etc/profile
. ~/.env

dinit &

exec "$@"

openrc can quickly kill emptty along with ~/.config/emptty sway.

tvrzna commented 1 year ago

I've meant emptty service termination, e.g. by rc-service emptty stop.

amano-kenji commented 1 year ago

If you want to implement user exit script, I want to be able to configure timeout for the script, or it should be a sensible value like 30 seconds.

tvrzna commented 1 year ago

I'm thinking about this implementation:

amano-kenji commented 1 year ago

I think that's good enough.