chiark / gitweb /
cgroup: don't allow hidden cgroups
[elogind.git] / src / basic / cgroup-util.c
index b3e92763cde20ca9526f83b2dfce79319f51f1d0..8fbbd30429d93452e74e078cdabac7fffb357a73 100644 (file)
@@ -113,7 +113,7 @@ int cg_read_subgroup(DIR *d, char **fn) {
         assert(d);
         assert(fn);
 
         assert(d);
         assert(fn);
 
-        FOREACH_DIRENT(de, d, return -errno) {
+        FOREACH_DIRENT_ALL(de, d, return -errno) {
                 char *b;
 
                 if (de->d_type != DT_DIR)
                 char *b;
 
                 if (de->d_type != DT_DIR)
@@ -321,6 +321,14 @@ int cg_migrate(const char *cfrom, const char *pfrom, const char *cto, const char
                         if (set_get(s, LONG_TO_PTR(pid)) == LONG_TO_PTR(pid))
                                 continue;
 
                         if (set_get(s, LONG_TO_PTR(pid)) == LONG_TO_PTR(pid))
                                 continue;
 
+                        /* Ignore kernel threads. Since they can only
+                         * exist in the root cgroup, we only check for
+                         * them there. */
+                        if (cfrom &&
+                            (isempty(pfrom) || path_equal(pfrom, "/")) &&
+                            is_kernel_thread(pid) > 0)
+                                continue;
+
                         r = cg_attach(cto, pto, pid);
                         if (r < 0) {
                                 if (ret >= 0 && r != -ESRCH)
                         r = cg_attach(cto, pto, pid);
                         if (r < 0) {
                                 if (ret >= 0 && r != -ESRCH)