From 454a2d5db50a2c1af1380239ea48e0ca8f456619 Mon Sep 17 00:00:00 2001
From: Brendan Jackman <brendan.jackman@arm.com>
Date: Mon, 28 Nov 2016 12:41:41 +0000
Subject: [PATCH] shutils/cgroups: Don't fail when racing with process exit

If a process is added to $PIDS but then exits before the
cgroups_task_move invokation finishes, then echoing its PID to
cgroups.procs results in an I/O error. If that process is the last in
$PIDS, then that failing echo command is the last of the function, so
the script exits with an error and devlib raises an exception.

Add `|| true` to avoid this problem.
---
 devlib/bin/scripts/shutils.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/devlib/bin/scripts/shutils.in b/devlib/bin/scripts/shutils.in
index 7a4ee0e..640d65d 100755
--- a/devlib/bin/scripts/shutils.in
+++ b/devlib/bin/scripts/shutils.in
@@ -163,7 +163,7 @@ cgroups_tasks_move() {
 	for TID in $PIDS; do
 	  COMM=`$CAT /proc/$TID/comm`
 	  echo "$TID : $COMM"
-	  echo $TID > $SRC_GRP/cgroup.procs
+	  echo $TID > $SRC_GRP/cgroup.procs || true
 	done
 }