Found this as well which has more information about how systemd might
shut down your user slice

https://serverfault.com/questions/1137788/how-to-debug-systemd-shutdown-failing-to-gracefully-shutdown
which lnks to 
https://www.freedesktop.org/software/systemd/man/latest/systemd.kill.html#KillMode=

if you've verified your process gets a KILL signal and no TERM before
hand, and the various unit / sessions settings are configured to send
TERM before KILL, I guess that would be a systemd bug. but I guess,
more likely than a bug, would be that the (potentially complicated)
interaction between how systemd manages processes and how it can be
configured is not configured to send a TERM first.

since there doesn't seem to be a way to turn on debugging so systemd
tells you what it's doing, you may have to either code up a patch to
add more logging to systemd, or manually check the (again, potentially
complicated) settings to see how those settings are telling systemd to
kill your user session / slice. that of course also requires
understanding what a session or slice even is, which I don't claim to
know.

not trying to be unhelpful here -- I was looking into this cuz I
wanted to learn more about systemd, and the answer seems to be "it's
potentially quite complicated"

On Fri, Mar 20, 2026 at 9:07 AM Daniel Sterling
<[email protected]> wrote:
>
> from https://github.com/systemd/systemd/blob/main/src/shutdown/shutdown.c
>
> it looks like systemd does indeed try to term then kill all processes
>
>         log_info("Sending SIGTERM to remaining processes...");
>         broadcast_signal(SIGTERM, true, true, arg_timeout);
>
>         log_info("Sending SIGKILL to remaining processes...");
>         broadcast_signal(SIGKILL, true, false, arg_timeout);
>
> do you see those entries in your logs?
>
> On Fri, Mar 20, 2026 at 8:33 AM alain williams <[email protected]> wrote:
> >
> > I find that when I do a reboot or poweroff (from command line) running
> > processes are not being sent SIGTERM. The one that really annoys me is a 
> > text
> > editor not receiving it and thus me losing work.
> >
> > The systemd documentation says that it should be sent; good old init used 
> > to do
> > this.
> >
> > Is the documentation wrong or do I need to tweak some config somewhere ?
> >
> > I am running Debian 13 with the mate desktop. MATE Terminal provides the
> > terminal emulation. The editor is my own version of microemacs (which does
> > handle SIGTERM correctly).
> >
> > The GUI (mate, etc) is actually irrelevant - the same thing happens to the
> > editor being run on a console.
> >
> > TIA
> >
> > --
> > Alain Williams
> > Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
> > Lecturer.
> > +44 (0) 787 668 0256  https://www.phcomp.co.uk/
> > Parliament Hill Computers. Registration Information: 
> > https://www.phcomp.co.uk/Contact.html
> > #include <std_disclaimer.h>
> >

Reply via email to