summaryrefslogtreecommitdiffstats
path: root/logcat
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2015-06-02 07:57:16 -0700
committerMark Salyzyn <salyzyn@google.com>2015-06-02 15:27:41 -0700
commitcdb468abb38bb75aaad5d4c6699a824559cf272a (patch)
treec43c9ee6ed212880b461a4908e300b0d03df13b4 /logcat
parent117c3220400bcffce74470ebcf2179d6845cb78b (diff)
downloadsystem_core-cdb468abb38bb75aaad5d4c6699a824559cf272a.zip
system_core-cdb468abb38bb75aaad5d4c6699a824559cf272a.tar.gz
system_core-cdb468abb38bb75aaad5d4c6699a824559cf272a.tar.bz2
logcat: -f run in background
(cherry pick from commit 3ef730c57f88ac24b0d6b021e43fc344d602fe36) - if saving to file, set SP_BACKGROUND policy - if saving to file, set BATCH priority - sort include files Bug: 19608716 Change-Id: I00acb8b8db0d2ff9ff36c97f9e74604d31938376
Diffstat (limited to 'logcat')
-rw-r--r--logcat/Android.mk2
-rw-r--r--logcat/logcat.cpp27
2 files changed, 20 insertions, 9 deletions
diff --git a/logcat/Android.mk b/logcat/Android.mk
index fd54915..7115f9b 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 afcc20a..6d7740e 100644
--- a/logcat/logcat.cpp
+++ b/logcat/logcat.cpp
@@ -1,36 +1,38 @@
// Copyright 2006-2015 The Android Open Source Project
+#include <arpa/inet.h>
#include <assert.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <math.h>
+#include <sched.h>
+#include <signal.h>
+#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
-#include <stdarg.h>
#include <string.h>
-#include <signal.h>
-#include <time.h>
-#include <unistd.h>
#include <sys/cdefs.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <arpa/inet.h>
+#include <time.h>
+#include <unistd.h>
#include <memory>
#include <string>
#include <base/file.h>
#include <base/strings.h>
+#include <cutils/sched_policy.h>
#include <cutils/sockets.h>
+#include <log/event_tag_map.h>
#include <log/log.h>
#include <log/log_read.h>
-#include <log/logger.h>
#include <log/logd.h>
+#include <log/logger.h>
#include <log/logprint.h>
-#include <log/event_tag_map.h>
#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(&param, 0, sizeof(param));
+ if (sched_setscheduler((pid_t) 0, SCHED_BATCH, &param) < 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");