libcutils: only change cgroup when fd is initialized

This is to avoid failues on setting non-exist cgroup

Bug: 34193533
Test: on marlin
Change-Id: I619dcba332fda9ec421df811745cf10311beddd3
This commit is contained in:
Wei Wang 2017-03-20 15:13:05 -07:00
parent a27a91a5fd
commit 97957fc420

View file

@ -464,7 +464,7 @@ int set_sched_policy(int tid, SchedPolicy policy)
break;
}
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;
}