diff options
| author | Elliott Hughes <enh@google.com> | 2016-06-06 21:19:55 -0700 |
|---|---|---|
| committer | Elliott Hughes <enh@google.com> | 2016-06-06 21:19:55 -0700 |
| commit | 8d532e47376859e2ea8f953ebe75d24560e80464 (patch) | |
| tree | ea9edc7539e6d0e7ce9515efa57a73a6e93e63e7 /libprocessgroup | |
| parent | 27a68ef007734929a6cfb46c233c5b1757f7786c (diff) | |
| parent | cea1d0465b400f25db6a85547381713746d39e36 (diff) | |
| download | core-8d532e47376859e2ea8f953ebe75d24560e80464.tar.gz core-8d532e47376859e2ea8f953ebe75d24560e80464.tar.bz2 core-8d532e47376859e2ea8f953ebe75d24560e80464.zip | |
resolve merge conflicts of cea1d04 to nyc-dev-plus-aosp
Change-Id: I41cdca717664a16f00fd1b28076dd752fa96653d
Diffstat (limited to 'libprocessgroup')
| -rw-r--r-- | libprocessgroup/Android.mk | 11 | ||||
| -rw-r--r-- | libprocessgroup/processgroup.cpp | 26 |
2 files changed, 23 insertions, 14 deletions
diff --git a/libprocessgroup/Android.mk b/libprocessgroup/Android.mk index 1885fa5dd..9620ebdd6 100644 --- a/libprocessgroup/Android.mk +++ b/libprocessgroup/Android.mk @@ -3,7 +3,16 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES := processgroup.cpp LOCAL_MODULE := libprocessgroup -LOCAL_SHARED_LIBRARIES := liblog libutils +LOCAL_STATIC_LIBRARIES := liblog +LOCAL_C_INCLUDES := $(LOCAL_PATH)/include +LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include +LOCAL_CFLAGS := -Wall -Werror +include $(BUILD_STATIC_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_SRC_FILES := processgroup.cpp +LOCAL_MODULE := libprocessgroup +LOCAL_SHARED_LIBRARIES := liblog LOCAL_C_INCLUDES := $(LOCAL_PATH)/include LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include LOCAL_CFLAGS := -Wall -Werror diff --git a/libprocessgroup/processgroup.cpp b/libprocessgroup/processgroup.cpp index cfc9ae2dc..c4672c48a 100644 --- a/libprocessgroup/processgroup.cpp +++ b/libprocessgroup/processgroup.cpp @@ -22,20 +22,19 @@ #include <errno.h> #include <fcntl.h> #include <inttypes.h> -#include <mutex> -#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> #include <sys/types.h> + +#include <chrono> #include <memory> +#include <mutex> #include <log/log.h> #include <private/android_filesystem_config.h> -#include <utils/SystemClock.h> - #include <processgroup/processgroup.h> // Uncomment line below use memory cgroups for keeping track of (forked) PIDs @@ -290,25 +289,26 @@ static int killProcessGroupOnce(uid_t uid, int initialPid, int signal) int killProcessGroup(uid_t uid, int initialPid, int signal) { - int processes; - const int sleep_us = 5 * 1000; // 5ms - int64_t startTime = android::uptimeMillis(); - int retry = 40; + std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); + int retry = 40; + int processes; while ((processes = killProcessGroupOnce(uid, initialPid, signal)) > 0) { SLOGV("killed %d processes for processgroup %d\n", processes, initialPid); if (retry > 0) { - usleep(sleep_us); + usleep(5 * 1000); // 5ms --retry; } else { - SLOGE("failed to kill %d processes for processgroup %d\n", - processes, initialPid); + SLOGE("failed to kill %d processes for processgroup %d\n", processes, initialPid); break; } } - SLOGV("Killed process group uid %d pid %d in %" PRId64 "ms, %d procs remain", uid, initialPid, - android::uptimeMillis()-startTime, processes); + std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); + + SLOGV("Killed process group uid %d pid %d in %dms, %d procs remain", uid, initialPid, + static_cast<int>(std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count()), + processes); if (processes == 0) { return removeProcessGroup(uid, initialPid); |
