1
0
mirror of https://github.com/ARM-software/devlib.git synced 2024-10-05 18:30:50 +01:00

Validate cgroups_run_into has taken effect

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.
This commit is contained in:
Sebastian Goscik 2024-05-22 11:27:56 +01:00 committed by Marc Bonnici
parent a28c6d7ce0
commit c9b539f722

View File

@ -154,7 +154,16 @@ cgroups_run_into() {
# Move this shell into that control group # Move this shell into that control group
echo $$ > $CGPATH/cgroup.procs echo $$ > $CGPATH/cgroup.procs
echo "Moving task into root CGroup ($CGPATH)" 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 done
if [ $? -ne 0 ]; then
exit 1
fi
# Execution under specified CGroup # Execution under specified CGroup
else else
@ -173,8 +182,16 @@ cgroups_run_into() {
# Move this shell into that control group # Move this shell into that control group
echo $$ > $CGPATH/cgroup.procs echo $$ > $CGPATH/cgroup.procs
echo "Moving task into $CGPATH" 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 done
if [ $? -ne 0 ]; then
exit 1
fi
fi fi
# Execute the command # Execute the command