public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
From: "Michal Koutný" <mkoutny-IBi9RG/b67k@public.gmane.org>
To: "R. Diez" <rdiez1999-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: cgroups mailinglist <cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: Wrapper to run a command in a temporary cgroup
Date: Tue, 5 Apr 2022 13:27:43 +0200	[thread overview]
Message-ID: <20220405112743.GC13806@blackbody.suse.cz> (raw)
In-Reply-To: <0174490d-8679-3885-df31-e9f6c1e7205b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Hello.

On Mon, Apr 04, 2022 at 02:25:27PM +0200, "R. Diez" <rdiez1999-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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


      parent reply	other threads:[~2022-04-05 11:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-04 12:25 Wrapper to run a command in a temporary cgroup R. Diez
     [not found] ` <0174490d-8679-3885-df31-e9f6c1e7205b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-04-05 11:27   ` Michal Koutný [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220405112743.GC13806@blackbody.suse.cz \
    --to=mkoutny-ibi9rg/b67k@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=rdiez1999-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox