diff --git a/logcat/Android.mk b/logcat/Android.mk index fd54915fd..7115f9ba9 100644 --- a/logcat/Android.mk +++ b/logcat/Android.mk @@ -5,7 +5,7 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES:= logcat.cpp event.logtags -LOCAL_SHARED_LIBRARIES := liblog libbase +LOCAL_SHARED_LIBRARIES := liblog libbase libcutils LOCAL_MODULE := logcat diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp index afcc20ae4..6d7740eaa 100644 --- a/logcat/logcat.cpp +++ b/logcat/logcat.cpp @@ -1,36 +1,38 @@ // Copyright 2006-2015 The Android Open Source Project +#include #include #include #include #include #include #include +#include +#include +#include #include #include -#include #include -#include -#include -#include #include #include #include #include -#include +#include +#include #include #include #include #include +#include #include +#include #include #include -#include #include +#include #include -#include #define DEFAULT_MAX_ROTATED_LOGS 4 @@ -209,7 +211,15 @@ static void setupOutput() g_outFD = STDOUT_FILENO; } else { - struct stat statbuf; + if (set_sched_policy(0, SP_BACKGROUND) < 0) { + fprintf(stderr, "failed to set background scheduling policy\n"); + } + + struct sched_param param; + memset(¶m, 0, sizeof(param)); + if (sched_setscheduler((pid_t) 0, SCHED_BATCH, ¶m) < 0) { + fprintf(stderr, "failed to set to batch scheduler\n"); + } g_outFD = openLogFile (g_outputFileName); @@ -217,6 +227,7 @@ static void setupOutput() logcat_panic(false, "couldn't open output file"); } + struct stat statbuf; if (fstat(g_outFD, &statbuf) == -1) { close(g_outFD); logcat_panic(false, "couldn't get output file stat\n");