5

When I try to close a logind session (by logging out), some processes remain running under the session, preventing it from properly terminating, resulting in user@uid.service not terminating either. I've heard that the latter is an intended behavior (it is desirable for some units to remain running), but I assume that leaving sessions running is not the proper way to achieve that. Furthermore, when I manually terminate the session, the user@uid.service also terminates, so it almost seems like lingering sessions are used for this purpose.

To illustrate what I'm on about, this is a part of the output of systemd-cgls while I am normally logged in (i.e. Right now):

Control group /:
-.slice
└─user.slice
  └─user-1000.slice
    ├─user@1000.service
    │ └─ //various units listed; removed for brevity
    └─session-c8.scope
      ├─4883 login -- sammko     
      ├─4905 /usr/bin/gnome-keyring-daemon --daemonize --login
      └─ //various other processes listed; removed for brevity

The output is completely expected. After logging out of the session:

Control group /:
-.slice
└─user.slice
  └─user-1000.slice
    ├─user@1000.service
    │ └─ //various units listed; removed for brevity
    └─session-c8.scope
      └─4905 /usr/bin/gnome-keyring-daemon --daemonize --login

gnome-keyring-daemon somehow survives, keeping the session alive. If we now run loginctl show-session c8, we find State=closing in the output. If we proceed to kill -HUP 4905 we find that the process and the session terminate, taking the entire user-uid.slice with it. If we were to proceed with kill -TERM 4905, the process would also have terminated. This makes me think that gnome-keyring-daemon does not ignore the signals, or anything like that. In case the process needed a signal twice to actually close, I tried to kill -HUP 4905 before logging out and the process terminated as well.

I was under the impression that systemd attempts to terminate processes with SIGHUP, to which gnome-keyring-daemon normally responds accordingly. (I have had gpg-agent linger along with it as well, and that successfully ignores SIGHUP. But that's a different story.)

So my question is: Why does gnome-keyring-daemon keep running after logging out for no apparent reason and how to resolve it, other than enabling KillUserProcesses.

Also, please note that this question is not related to the changes in systemd-230

2
  • Very nice question yet an other messy thing with systemd... this also happen if you run a script that call sleep or loop sleep (it get stuck and does not terminate) – intika May 15 '19 at 1:48
  • Is there an answer for this? I'm having similar problems with non-terminating sessions on a multi-user computer. – mathbekunkus Jul 28 '20 at 5:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.