From 97957fc420b0d2dc019f4728b2d3611b7305ab91 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Mon, 20 Mar 2017 15:13:05 -0700 Subject: [PATCH] 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 --- libcutils/sched_policy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcutils/sched_policy.cpp b/libcutils/sched_policy.cpp index 7e3ad593e..40144cf16 100644 --- a/libcutils/sched_policy.cpp +++ b/libcutils/sched_policy.cpp @@ -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; }