Use sched_policy to avoid hard-coded cpuctl path
Change-Id: I8f62287d1b60d8eef72d1dfc64be5c3d56e9f498
diff --git a/logwrapper.c b/logwrapper.c
index 8ef583b..34a1e5a 100644
--- a/logwrapper.c
+++ b/logwrapper.c
@@ -25,6 +25,7 @@
#include "private/android_filesystem_config.h"
#include "cutils/log.h"
+#include "cutils/sched_policy.h"
int parent(const char *tag, int parent_read) {
int status;
@@ -148,18 +149,10 @@
close(child_ptty);
if (background) {
- int fd = open("/dev/cpuctl/bg_non_interactive/tasks", O_WRONLY);
- if (fd >= 0) {
- char text[64];
- sprintf(text, "%d", getpid());
- if (write(fd, text, strlen(text)) < 0) {
- ALOG(LOG_WARN, "logwrapper",
- "Unable to background process (%s)", strerror(errno));
- }
- close(fd);
- } else {
+ int err = set_sched_policy(getpid(), SP_BACKGROUND);
+ if (err < 0) {
ALOG(LOG_WARN, "logwrapper",
- "Unable to background process (%s)", strerror(errno));
+ "Unable to background process (%s)", strerror(-err));
}
}