chiark / gitweb /
cgroup: never migrate kernel threads out of the root cgroup
[elogind.git] / src / basic / cgroup-util.c
index b1063e9db9991819e40f8ab252edc5d5860ef5a7..f96cd6339402e8182c32f00349dad11b2d704149 100644 (file)
@@ -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;
 
+                        /* 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)
@@ -1357,8 +1365,6 @@ int cg_path_get_user_unit(const char *path, char **ret) {
         return cg_path_get_unit(t, ret);
 }
 
-/// UNNEDED by elogind
-#if 0
 int cg_pid_get_user_unit(pid_t pid, char **unit) {
         _cleanup_free_ char *cgroup = NULL;
         int r;
@@ -1371,7 +1377,6 @@ int cg_pid_get_user_unit(pid_t pid, char **unit) {
 
         return cg_path_get_user_unit(cgroup, unit);
 }
-#endif // 0
 
 int cg_path_get_machine_name(const char *path, char **machine) {
         _cleanup_free_ char *u = NULL, *sl = NULL;
@@ -1388,8 +1393,6 @@ int cg_path_get_machine_name(const char *path, char **machine) {
         return readlink_malloc(sl, machine);
 }
 
-/// UNNEDED by elogind
-#if 0
 int cg_pid_get_machine_name(pid_t pid, char **machine) {
         _cleanup_free_ char *cgroup = NULL;
         int r;
@@ -1402,7 +1405,6 @@ int cg_pid_get_machine_name(pid_t pid, char **machine) {
 
         return cg_path_get_machine_name(cgroup, machine);
 }
-#endif // 0
 
 int cg_path_get_session(const char *path, char **session) {
         _cleanup_free_ char *unit = NULL;
@@ -1475,8 +1477,6 @@ int cg_path_get_owner_uid(const char *path, uid_t *uid) {
         return 0;
 }
 
-/// UNNEDED by elogind
-#if 0
 int cg_pid_get_owner_uid(pid_t pid, uid_t *uid) {
         _cleanup_free_ char *cgroup = NULL;
         int r;
@@ -1487,7 +1487,6 @@ int cg_pid_get_owner_uid(pid_t pid, uid_t *uid) {
 
         return cg_path_get_owner_uid(cgroup, uid);
 }
-#endif // 0
 
 int cg_path_get_slice(const char *p, char **slice) {
         const char *e = NULL;