diff options
author | James Hawkins <jhawkins@google.com> | 2016-02-19 11:10:30 -0800 |
---|---|---|
committer | James Hawkins <jhawkins@google.com> | 2016-02-19 11:10:30 -0800 |
commit | 22b6f7a559e02f44442a1f5079d790884971d7f2 (patch) | |
tree | e81614a7a604616a0fff892f26b1f316664cec26 /libprocessgroup/processgroup.cpp | |
parent | fb516c2e635677cf7f7ad8c0eee27329b245cc54 (diff) | |
parent | 0f5d443d0ccc3d3d95604b241cdd23117363f849 (diff) | |
download | core-22b6f7a559e02f44442a1f5079d790884971d7f2.tar.gz core-22b6f7a559e02f44442a1f5079d790884971d7f2.tar.bz2 core-22b6f7a559e02f44442a1f5079d790884971d7f2.zip |
resolve merge conflicts of 0f5d443d0c to nyc-dev-plus-aosp
Change-Id: I850bda0808ae17ade5bc0e667211a599d284d6e3
Diffstat (limited to 'libprocessgroup/processgroup.cpp')
-rw-r--r-- | libprocessgroup/processgroup.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/libprocessgroup/processgroup.cpp b/libprocessgroup/processgroup.cpp index 5ab957d86..ba97f32f7 100644 --- a/libprocessgroup/processgroup.cpp +++ b/libprocessgroup/processgroup.cpp @@ -29,6 +29,7 @@ #include <string.h> #include <sys/stat.h> #include <sys/types.h> +#include <memory> #include <log/log.h> #include <private/android_filesystem_config.h> @@ -194,11 +195,11 @@ static int removeProcessGroup(uid_t uid, int pid) static void removeUidProcessGroups(const char *uid_path) { - DIR *uid = opendir(uid_path); + std::unique_ptr<DIR, decltype(&closedir)> uid(opendir(uid_path), closedir); if (uid != NULL) { struct dirent cur; struct dirent *dir; - while ((readdir_r(uid, &cur, &dir) == 0) && dir) { + while ((readdir_r(uid.get(), &cur, &dir) == 0) && dir) { char path[PROCESSGROUP_MAX_PATH_LEN]; if (dir->d_type != DT_DIR) { @@ -213,7 +214,6 @@ static void removeUidProcessGroups(const char *uid_path) SLOGV("removing %s\n", path); rmdir(path); } - closedir(uid); } } @@ -221,13 +221,13 @@ void removeAllProcessGroups() { SLOGV("removeAllProcessGroups()"); const char *cgroup_root_path = getCgroupRootPath(); - DIR *root = opendir(cgroup_root_path); + std::unique_ptr<DIR, decltype(&closedir)> root(opendir(cgroup_root_path), closedir); if (root == NULL) { SLOGE("failed to open %s: %s", cgroup_root_path, strerror(errno)); } else { struct dirent cur; struct dirent *dir; - while ((readdir_r(root, &cur, &dir) == 0) && dir) { + while ((readdir_r(root.get(), &cur, &dir) == 0) && dir) { char path[PROCESSGROUP_MAX_PATH_LEN]; if (dir->d_type != DT_DIR) { @@ -242,7 +242,6 @@ void removeAllProcessGroups() SLOGV("removing %s\n", path); rmdir(path); } - closedir(root); } } |