LIST_REMOVE(Session, sessions_by_seat, s->seat->sessions, s);
}
+ if (s->cgroup_path)
+ hashmap_remove(s->manager->cgroups, s->cgroup_path);
+
free(s->cgroup_path);
strv_free(s->controllers);
}
}
+ hashmap_put(s->manager->cgroups, s->cgroup_path, s);
+
return 0;
}
if (s->started)
return 0;
+ r = user_start(s->user);
+ if (r < 0)
+ return r;
+
log_info("New session %s of user %s.", s->id, s->user->name);
/* Create cgroup */
static bool session_shall_kill(Session *s) {
assert(s);
- return s->kill_processes;
+ if (!s->kill_processes)
+ return false;
+
+ if (strv_contains(s->manager->kill_exclude_users, s->user->name))
+ return false;
+
+ if (strv_isempty(s->manager->kill_only_users))
+ return true;
+
+ return strv_contains(s->manager->kill_only_users, s->user->name);
}
static int session_kill_cgroup(Session *s) {
STRV_FOREACH(k, s->user->manager->controllers)
cg_trim(*k, s->cgroup_path, true);
+ hashmap_remove(s->manager->cgroups, s->cgroup_path);
+
free(s->cgroup_path);
s->cgroup_path = NULL;
assert(s);
- if (!s->started)
- return 0;
-
- log_info("Removed session %s.", s->id);
+ if (s->started)
+ log_info("Removed session %s.", s->id);
/* Kill cgroup */
k = session_kill_cgroup(s);
unlink(s->state_file);
session_add_to_gc_queue(s);
+ user_add_to_gc_queue(s->user);
- session_send_signal(s, false);
+ if (s->started)
+ session_send_signal(s, false);
if (s->seat) {
if (s->seat->active == s)