nodm icon indicating copy to clipboard operation
nodm copied to clipboard

When systemd tries to kill nodm, nodm restarts itself instead

Open mkaito opened this issue 7 years ago • 27 comments

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

mkaito avatar Nov 02 '16 20:11 mkaito

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

ndchugn avatar Dec 06 '16 03:12 ndchugn

This should be solved by https://github.com/spanezz/nodm/commit/ede6a3ff5249932963fdce5d337c3cfbdf0ef01a.

Feel free to reopen, if not.

sunweaver avatar Jan 23 '17 12:01 sunweaver

Doesn't look like it is.

eugene2k avatar Jan 28 '17 20:01 eugene2k

Not fixed for me either with version 0.13-1.3.

PatrickNowak avatar Jun 14 '17 11:06 PatrickNowak

As far as I can tell, not fixed.

mkaito avatar Jun 20 '17 22:06 mkaito

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

r-darwish avatar Jun 25 '17 19:06 r-darwish

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

sunweaver avatar Jun 26 '17 08:06 sunweaver

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.

needs avatar Jun 26 '17 22:06 needs

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

MikeMitterer avatar Jun 28 '17 09:06 MikeMitterer

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

felixsanz avatar Aug 02 '17 21:08 felixsanz

Actually, it's probably systemd killing the wrong PID.

Quoting Félix Sanz (2017-08-02 22:22:30)

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

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/spanezz/nodm/issues/5#issuecomment-319802619

mkaito avatar Aug 03 '17 04:08 mkaito

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

rtandy avatar Aug 04 '17 17:08 rtandy

It's probably the same problem. I reported this here because the Arch maintainer told me to.

On Fri, Aug 04, 2017 at 05:31:23PM +0000, Ryan Tandy wrote:

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

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/spanezz/nodm/issues/5#issuecomment-320307792

-- Michishige Kaito

BOFH excuse #106:

The electrician didn't know what the yellow cable was so he yanked the ethernet out.

mkaito avatar Aug 05 '17 02:08 mkaito

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?

barnacs avatar Aug 27 '17 02:08 barnacs

This fixes for me.

slashblog avatar Aug 27 '17 05:08 slashblog

Hi,

On So 27 Aug 2017 07:55:53 CEST, slashblog wrote:

This fixes for
me.

Please file a PR, add proper "Fixes " statement to the commit
message of the above commit.

Thanks! Mike

DAS-NETZWERKTEAM mike gabriel, herweg 7, 24357 fleckeby mobile: +49 (1520) 1976 148 landline: +49 (4354) 8390 139

GnuPG Fingerprint: 9BFB AEE8 6C0A A5FF BF22 0782 9AF4 6B30 2577 1B31 mail: [email protected], http://das-netzwerkteam.de

sunweaver avatar Aug 27 '17 06:08 sunweaver

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.

slashblog avatar Aug 27 '17 14:08 slashblog

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.

barnacs avatar Aug 27 '17 15:08 barnacs

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

aario avatar Sep 12 '18 22:09 aario

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

felixsanz avatar Sep 12 '18 22:09 felixsanz

@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.

eugene2k avatar Sep 13 '18 05:09 eugene2k

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

daid avatar Sep 13 '18 19:09 daid

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

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

aario avatar Sep 29 '18 18:09 aario

@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.

aario avatar Sep 29 '18 18:09 aario

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

geolaw avatar Dec 27 '18 17:12 geolaw

The bug is still here in Debian testing (bullseye)

sagb avatar Dec 03 '20 12:12 sagb

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".

luigifab avatar Dec 03 '20 17:12 luigifab