OSDN Git Service

libcutils: only change cgroup when fd is initialized [ DO NOT MERGE ]
authorWei Wang <wvw@google.com>
Mon, 20 Mar 2017 22:13:05 +0000 (15:13 -0700)
committerandroid-build-team Robot <android-build-team-robot@google.com>
Thu, 18 May 2017 00:52:41 +0000 (00:52 +0000)
This is to avoid failues on setting non-exist cgroup

Bug: 34193533
Test: on marlin
Change-Id: I619dcba332fda9ec421df811745cf10311beddd3
(cherry picked from commit e46aae223626432bde7d4e95818e8394664c6c02)

libcutils/sched_policy.c

index 05a2048..6d90589 100644 (file)
@@ -404,7 +404,7 @@ int set_sched_policy(int tid, SchedPolicy policy)
         }
 
 
-        if (add_tid_to_cgroup(tid, fd) != 0) {
+        if (fd > 0 && add_tid_to_cgroup(tid, fd) != 0) {
             if (errno != ESRCH && errno != ENOENT)
                 return -errno;
         }