Re: [systemd-devel] What are Abandon() and AbandonScope() used for?

2024-01-30 Thread Felip Moll
>
> > When should I use this? For example I am creating a scope which will
> > allocate some pids into their cgroups. The scope is created from a daemon
> > run from a service unit. The service will eventually be shut down and I
> > want the scope to remain if it has pids in it. Should the service
> "abandon"
> > the scope?
>
> That depends whether you want some extra stopping procedure for your
> scope besides regular SIGTERM logic.
>

Cool, so if I just want systemd to send a SIGTERM when OS is shutting down
or when a user does "systemctl stop my.scope", and I do not need any "extra
stopping procedure" (don't know what exactly this is), then I don't need to
Abandon the scope.
It has nothing to do then about keeping a scope when the process that
initiated it has already terminated.


Re: [systemd-devel] What are Abandon() and AbandonScope() used for?

2024-01-30 Thread Michal Koutný
Hello.

On Tue, Jan 23, 2024 at 04:40:35PM +0100, Felip Moll  wrote:
> Can somebody give me an insight of what these methods really do?
> The documentation is pretty vague:
> https://www.freedesktop.org/wiki/Software/systemd/dbus/

Those would most probably pair with
org.freedesktop.systemd1.Scope.RequestStop DBus signal -- an organized
way how systemd stops scope.

I.e. there can be a "controller" of the scope that would respond to such a
signal with some graceful termination of the scope. Lifetimes of the
scope and controller may be independent and when controller terminates,
it can mark the scope as abandoned (instead of killing its processes or
disappearing without notice).

That's the theory, practice would be logind~controller of its session
scopes.

> When should I use this? For example I am creating a scope which will
> allocate some pids into their cgroups. The scope is created from a daemon
> run from a service unit. The service will eventually be shut down and I
> want the scope to remain if it has pids in it. Should the service "abandon"
> the scope?

That depends whether you want some extra stopping procedure for your
scope besides regular SIGTERM logic.

HTH,
Michal


signature.asc
Description: PGP signature


[systemd-devel] What are Abandon() and AbandonScope() used for?

2024-01-23 Thread Felip Moll
Hello,
Can somebody give me an insight of what these methods really do?
The documentation is pretty vague:
https://www.freedesktop.org/wiki/Software/systemd/dbus/

When should I use this? For example I am creating a scope which will
allocate some pids into their cgroups. The scope is created from a daemon
run from a service unit. The service will eventually be shut down and I
want the scope to remain if it has pids in it. Should the service "abandon"
the scope?

Commit a911bb9ab27ac0eb3 says:

When a process dies that we can associate with a specific unit, start
watching all other processes of that unit, so that we can associate
those processes with the unit too.

What does "watching a process" mean?
Are these methods intended to be used only by logind?
Thanks