Re: Wrapper to run a command in a temporary cgroup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.

On Mon, Apr 04, 2022 at 02:25:27PM +0200, "R. Diez" <rdiez1999@xxxxxxxxx> wrote:
> run-on-temporary-cgroup.sh cmd arg1 ... argn.
> 
> The tool should create a temporary cgroup, run the process inside, and
> return the same exit code as the user command.

This sounds very much like `systemd-run --scope`.

> Those requirements are similar to what systemd-run does, but I need an
> alternative which does not depend on systemd.

Fair enough.

> Even if you have systemd, systemd-run is rather convenient, but it is
> somewhat heavy weight 

Then a suggestion of using a container runtime is likely out of question
too.

> If there is no such a tool, can someone give me some hints on how to
> implement one? Is it possible in Shell or Perl? Or do I need to reach
> to C / C++? Is there anything similar I could take as basis?

There's also libcg [1] (whose cgroup v2 support is WIP AFAIK) with its
cgexec utility. I don't know other tools (besides the named previously).

You can implement it in whatever environment that can interact with
filesystem (and perhaps poll for events), it's all documented in [2]
(alternatively [3], which I'd discourage for a new project).

HTH,
Michal

[1] https://github.com/libcgroup/libcgroup/blob/main/README
[2] https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html
[3] https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v1/cgroups.html




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [Monitors]

  Powered by Linux