diff options
author | Bart Van Assche <bvanassche@google.com> | 2023-11-15 07:47:05 -0800 |
---|---|---|
committer | Bart Van Assche <bvanassche@google.com> | 2023-11-27 14:13:46 -0800 |
commit | a43b96c157d61f1d25b9a20cdd59eb77519175c7 (patch) | |
tree | 7c53719387113a3c7b7d746fbaf9feb2313b9d12 /libprocessgroup | |
parent | 455fb82bf9418dcc15ddc985c489321b74b36846 (diff) | |
download | core-a43b96c157d61f1d25b9a20cdd59eb77519175c7.tar.gz |
libprocessgroup: Stop services that have been migrated to another v2 cgroup
CL 2828279 doesn't do what it's description says that it does. Making
Service::Stop() work for processes that have been migrated to another v2
cgroup requires changing DoKillProcessGroupOnce(). Hence this CL that
removes the early return statements from DoKillProcessGroupOnce().
Bug: 308900853
Change-Id: Ib798555feeb95a786a619c3d7013c7d5829b01ad
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Diffstat (limited to 'libprocessgroup')
-rw-r--r-- | libprocessgroup/processgroup.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libprocessgroup/processgroup.cpp b/libprocessgroup/processgroup.cpp index 76868bbd2..f594f7f66 100644 --- a/libprocessgroup/processgroup.cpp +++ b/libprocessgroup/processgroup.cpp @@ -378,8 +378,11 @@ static int DoKillProcessGroupOnce(const char* cgroup, uid_t uid, int initialPid, fd.reset(fopen(path.c_str(), "re")); if (!fd) { if (errno == ENOENT) { - // This happens when process is already dead - return 0; + // This happens when the process is already dead or if, as the result of a bug, it + // has been migrated to another cgroup. An example of a bug that can cause migration + // to another cgroup is using the JoinCgroup action with a cgroup controller that + // has been activated in the v2 cgroup hierarchy. + goto kill; } PLOG(WARNING) << __func__ << " failed to open process cgroup uid " << uid << " pid " << initialPid; @@ -418,6 +421,7 @@ static int DoKillProcessGroupOnce(const char* cgroup, uid_t uid, int initialPid, } } +kill: // Kill all process groups. for (const auto pgid : pgids) { LOG(VERBOSE) << "Killing process group " << -pgid << " in uid " << uid |