Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When systemd tries to kill nodm, nodm restarts itself instead #5

Open
mkaito opened this issue Nov 2, 2016 · 27 comments · May be fixed by #13
Open

When systemd tries to kill nodm, nodm restarts itself instead #5

mkaito opened this issue Nov 2, 2016 · 27 comments · May be fixed by #13

Comments

@mkaito
Copy link

mkaito commented Nov 2, 2016

I suppose systemd is trying to kill the wrong PID. Eventually, the kill operation times out and systemd hard-kills the process. This happens, for example, when trying to reboot or halt the computer.

Arch Linux, everything up to date.
Nodm version 0.12

Here's the systemd service file:

[Unit]
Description=nodm display manager

[Service]
EnvironmentFile=/etc/nodm.conf
ExecStart=/usr/bin/nodm

[Install]
WantedBy=multi-user.target
@ndchugn
Copy link

ndchugn commented Dec 6, 2016

same with me, sometime i have to press on power button to turnoff the laptop

@sunweaver
Copy link
Collaborator

This should be solved by ede6a3f.

Feel free to reopen, if not.

@eugene2k
Copy link

Doesn't look like it is.

@PatrickNowak
Copy link

Not fixed for me either with version 0.13-1.3.

@mkaito
Copy link
Author

mkaito commented Jun 20, 2017

As far as I can tell, not fixed.

@r-darwish
Copy link

@sunweaver can you please reopen the issue? It seems that it is still relevant

@sunweaver
Copy link
Collaborator

@r-darwish: Ack. Reopened. Patches are welcome!

@sunweaver sunweaver reopened this Jun 26, 2017
@needs
Copy link

needs commented Jun 26, 2017

Could this line be what cause this issue? It seems like once the session lasted longer than NODM_MIN_SESSION_TIME, it shouldn't be restarted if it ends. Changing it to something like return E_SUCCESS; should do the trick.

Also, I tried and failed to get my build of nodm working on my computer to test this change. I don't want to submit a completely untested pull request.

@MikeMitterer
Copy link

I just found this old bug report: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=531869
You think it's somehow related?

@felixsanz
Copy link

This is very annoying. Any idea whats going on? Anyone working on it? I think nodm is ignoring system run levels. It shouldn't restart itself when system is moving into restart/shutdown levels

@mkaito
Copy link
Author

mkaito commented Aug 3, 2017 via email

@rtandy
Copy link
Contributor

rtandy commented Aug 4, 2017

This sounds pretty similar to my Debian bug report: https://bugs.debian.org/785592

@mkaito
Copy link
Author

mkaito commented Aug 5, 2017 via email

@barnacs
Copy link

barnacs commented Aug 27, 2017

I'm also experiencing this issue, though it doesn't seem to be deterministic, sometimes it shuts down cleanly. My guess based on the logs and a look at the code:

  • session is killed by systemd
  • nodm_display_manager_wait has E_SESSION_DIED
  • before shutdown_quit_notification is called nodm receives SIGTERM, interrupt sets quit_signal_caught
  • nodm_display_manager_wait returns E_SESSION_DIED
  • nodm_display_manager_wait_restart_loop restarts the session, loops around reentering nodm_display_manager_wait, which clears quit_signal_caught

Is there a reason the signal is not acted on immediately by exiting in the handler?

@slashblog
Copy link

This fixes for me.

@sunweaver
Copy link
Collaborator

sunweaver commented Aug 27, 2017 via email

slashblog added a commit to slashblog/nodm that referenced this issue Aug 27, 2017
Fixes When systemd tries to kill nodm, nodm restarts itself instead spanezz#5
slashblog added a commit to slashblog/nodm that referenced this issue Aug 27, 2017
Fixes: When systemd tries to kill nodm, nodm restarts itself instead spanezz#5
@slashblog
Copy link

slashblog commented Aug 27, 2017

I have created the following pull request: it works for me. The following describes the issue:

The issue is that shutdown_quit_notification blocks signals. In nodm_display_manager_wait function there is waitpid call. This returns -1 if signal was received before session (dm->session.pid) was closed by systemctl. This is the happy scenario.

However, if session gets closed before signal was sent to the process. The waitpid returns dm->session.pid and the call to shutdown_quit_notification blocks SIGTERM. Due to this, catch_signals is never called and nodm proceeds to restarting display manager.

I have removed function shutdown_quit_notification altogether, as I don't see any need for it, since IMO there is no need to block these signals.

@barnacs
Copy link

barnacs commented Aug 27, 2017

I wonder if there's any need for the custom signal handling at all in the parent process. My solution was to remove it all and let the kernel exit/clean up. It works for my use case but I'm probably missing something.

dgw pushed a commit to dgw/nodm that referenced this issue May 10, 2018
Fixes spanezz#5, nodm will now correctly shut down instead of restarting when
systemd tries to kill it
@dgw dgw linked a pull request May 10, 2018 that will close this issue
@aario
Copy link

aario commented Sep 12, 2018

This bug is open since years ago! Almost two years! Seriously? I have to develop it myself?!

@felixsanz
Copy link

@aario you just better spend time with math subtracting. 2018 - 2016 = 2

@eugene2k
Copy link

@aario dgw's pull request fixes the bug, so you don't actually have to develop anything yourself. Just merge the pull request into your repo. Nodm seems unmaintained though.

@daid
Copy link

daid commented Sep 13, 2018

See #8, seems it needs a new maintainer, or it will "die".

@aario
Copy link

aario commented Sep 29, 2018

@aario you just better spend time with math subtracting. 2018 - 2016 = 2

Fixed my comment. (That was midnight! ;-) )

@aario
Copy link

aario commented Sep 29, 2018

@aario dgw's pull request fixes the bug, so you don't actually have to develop anything yourself. Just merge the pull request into your repo. Nodm seems unmaintained though.

Thanks for pointing me to right direction.

@geolaw
Copy link

geolaw commented Dec 27, 2018

I'm using nodm on a mac mini without a keyboard/mouse. Nodm logs me in, .xinitrc startx i3 and synergy
It maybe dead but it does the job in my case.

This may not the best way to handle this but it works for me
I've added this to /usr/lib/systemd/system/nodm.service

ExecStop=killall -9 nodm

shuts down every time

@sagb
Copy link

sagb commented Dec 3, 2020

The bug is still here in Debian testing (bullseye)

@luigifab
Copy link

luigifab commented Dec 3, 2020

For me, ExecStop=killall -9 nodm in /lib/systemd/system/nodm.service fix the bug in Debian testing.
Nodm doesn't restart my session when .xinitrc run systemctl poweroff.

Howewer, when I service nodm stop, the display doesn't back to "tty1".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.