Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Please login to access the resource
SUSE:SLE-15-SP1:GA
libcgroup.14591
0001-api.c-change-cgroup-of-every-thread-of-a-p...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-api.c-change-cgroup-of-every-thread-of-a-process.patch of Package libcgroup.14591
From 10f5f86c7007a62d52fb34ca9c15437477a11df4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com> Date: Tue, 8 Dec 2015 17:09:08 +0100 Subject: [PATCH 1/2] api.c: change cgroup of every thread of a process When changing cgroup of multi-threaded process, only the main threads cgroup actually changed. Now all threads of a process are enumerated and cgroup is changed for each of them. --- src/api.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/api.c b/src/api.c index bfd0177..27c9540 100644 --- a/src/api.c +++ b/src/api.c @@ -3108,10 +3108,13 @@ int cgroup_change_all_cgroups(void) return -ECGOTHER; while ((pid_dir = readdir(dir)) != NULL) { - int err, pid; + int err, pid, tid; uid_t euid; gid_t egid; char *procname = NULL; + DIR *tdir; + struct dirent *tid_dir = NULL; + char tpath[FILENAME_MAX] = { '\0' }; err = sscanf(pid_dir->d_name, "%i", &pid); if (err < 1) @@ -3125,11 +3128,24 @@ int cgroup_change_all_cgroups(void) if (err) continue; - err = cgroup_change_cgroup_flags(euid, - egid, procname, pid, CGFLAG_USECACHE); - if (err) - cgroup_dbg("cgroup change pid %i failed\n", pid); + snprintf(tpath, FILENAME_MAX, "%s%d/task/", path, pid); + + tdir = opendir(tpath); + if (!tdir) + continue; + + while ((tid_dir = readdir(tdir)) != NULL) { + err = sscanf(tid_dir->d_name, "%i", &tid); + if (err < 1) + continue; + + err = cgroup_change_cgroup_flags(euid, + egid, procname, tid, CGFLAG_USECACHE); + if (err) + cgroup_dbg("cgroup change tid %i failed\n", tid); + } + closedir(tdir); free(procname); } -- 2.16.4
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor