source: common/run-in-cgroup.sh@ 8e9343b

ablfs-more trunk
Last change on this file since 8e9343b was 8e9343b, checked in by Pierre Labastie <pierre.labastie@…>, 7 months ago

Add forgotten run-with-cgroup.sh script

  • Property mode set to 100755
File size: 529 bytes
Line 
1#!/bin/bash
2
3if [ -z "$CPUSPEC" ] || [ "$#" -lt 1 ]; then
4 echo "usage: CPUSPEC=... $0 command"
5 exit 1
6fi
7
8set +e
9
10if type systemd-run >/dev/null 2>&1 ; then
11 sudo systemd-run -G --pty -d --uid=$(whoami) -p AllowedCPUs="$CPUSPEC" "$@"
12else
13 sudo mkdir /sys/fs/cgroup/jhalfs
14 sudo sh -c "echo +cpuset > /sys/fs/cgroup/cgroup.subtree_control"
15 sudo sh -c "echo \"$CPUSPEC\" > /sys/fs/cgroup/jhalfs/cpuset.cpus"
16 (sudo sh -c "echo $BASHPID > /sys/fs/cgroup/jhalfs/cgroup.procs" &&
17 exec "$@")
18 sudo rmdir /sys/fs/cgroup/jhalfs
19fi
Note: See TracBrowser for help on using the repository browser.