public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
From: "R. Diez" <rdiez1999-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: cgroups mailinglist <cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Wrapper to run a command in a temporary cgroup
Date: Mon, 4 Apr 2022 14:25:27 +0200	[thread overview]
Message-ID: <0174490d-8679-3885-df31-e9f6c1e7205b@gmail.com> (raw)

Hi all:

I am looking for a wrapper script like this:

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.

I may want to limit the amount of memory the cgroup is allowed to consume. But more importantly, I want the tool to return when all processes in the cgroup (the user command an any children) have already terminated. This is apparently not so easy to achieve without cgroups.

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

Even if you have systemd, systemd-run is rather convenient, but it is somewhat heavy weight and it has issues with some signals (like SIGTERM), and with escaping/quoting, depending on the mode (--scope vs --wait).

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?

Apologies if this is not the right mailing list. I could not find anywhere else to ask about cgroups matters.

Regards,
   rdiez

             reply	other threads:[~2022-04-04 12:25 UTC|newest]

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

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=0174490d-8679-3885-df31-e9f6c1e7205b@gmail.com \
    --to=rdiez1999-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@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