Skip to content

Commit

Permalink
Validate cgroups_run_into has taken effect
Browse files Browse the repository at this point in the history
On some systems this seems to have no effect, leaving the executed shell in the root cgroup. Before, this function would still execute and the end user would think the desired process was run in the cgroup when infact it had not.
  • Loading branch information
ep1cman authored and marcbonnici committed Jun 12, 2024
1 parent a28c6d7 commit c9b539f
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion devlib/bin/scripts/shutils.in
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,16 @@ cgroups_run_into() {
# Move this shell into that control group
echo $$ > $CGPATH/cgroup.procs
echo "Moving task into root CGroup ($CGPATH)"
# Check the move actually worked
$GREP -E "$$" $CGPATH/cgroup.procs >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "ERROR: Process was not moved into $CGP"
exit 1
fi
done
if [ $? -ne 0 ]; then
exit 1
fi

# Execution under specified CGroup
else
Expand All @@ -173,8 +182,16 @@ cgroups_run_into() {
# Move this shell into that control group
echo $$ > $CGPATH/cgroup.procs
echo "Moving task into $CGPATH"
# Check the move actually worked
$GREP -E "$$" $CGPATH/cgroup.procs >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "ERROR: Process was not moved into $CGP"
exit 1
fi
done

if [ $? -ne 0 ]; then
exit 1
fi
fi

# Execute the command
Expand Down

0 comments on commit c9b539f

Please sign in to comment.