summaryrefslogtreecommitdiff
path: root/src/manager.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-07-11 00:50:49 +0200
committerLennart Poettering <lennart@poettering.net>2010-07-11 00:50:49 +0200
commitc6c18be35bb1d300d0b62a568783cc1c477f7151 (patch)
treee4bad2452f20b6d1d6df9714d6abe72cdc56599c /src/manager.c
parent55096547212928b0ba83fca2595cae0d66d3c0b0 (diff)
cgroup: kill processes, not tasks and other cgroup changes
Diffstat (limited to 'src/manager.c')
-rw-r--r--src/manager.c27
1 files changed, 6 insertions, 21 deletions
diff --git a/src/manager.c b/src/manager.c
index 8d016b9f5d..a7e24eb812 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -186,7 +186,6 @@ static int manager_setup_signals(Manager *m) {
int manager_new(ManagerRunningAs running_as, Manager **_m) {
Manager *m;
int r = -ENOMEM;
- char *p;
assert(_m);
assert(running_as >= 0);
@@ -245,14 +244,6 @@ int manager_new(ManagerRunningAs running_as, Manager **_m) {
if ((r = bus_init(m)) < 0)
goto fail;
- if (asprintf(&p, "%s/%s", m->cgroup_mount_point, m->cgroup_hierarchy) < 0) {
- r = -ENOMEM;
- goto fail;
- }
-
- m->pin_cgroupfs_fd = open(p, O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY|O_NONBLOCK);
- free(p);
-
*_m = m;
return 0;
@@ -420,8 +411,7 @@ void manager_free(Manager *m) {
/* If we reexecute ourselves, we keep the root cgroup
* around */
- if (m->exit_code != MANAGER_REEXECUTE)
- manager_shutdown_cgroup(m);
+ manager_shutdown_cgroup(m, m->exit_code != MANAGER_REEXECUTE);
bus_done(m);
@@ -443,13 +433,8 @@ void manager_free(Manager *m) {
lookup_paths_free(&m->lookup_paths);
strv_free(m->environment);
- free(m->cgroup_hierarchy);
- free(m->cgroup_mount_point);
-
hashmap_free(m->cgroup_bondings);
-
- if (m->pin_cgroupfs_fd >= 0)
- close_nointr_nofail(m->pin_cgroupfs_fd);
+ set_free_free(m->unit_path_cache);
free(m);
}
@@ -1664,7 +1649,7 @@ static int manager_process_notify_fd(Manager *m) {
ucred = (struct ucred*) CMSG_DATA(&control.cmsghdr);
- if (!(u = hashmap_get(m->watch_pids, UINT32_TO_PTR(ucred->pid))))
+ if (!(u = hashmap_get(m->watch_pids, LONG_TO_PTR(ucred->pid))))
if (!(u = cgroup_unit_by_pid(m, ucred->pid))) {
log_warning("Cannot find unit for notify message of PID %lu.", (unsigned long) ucred->pid);
continue;
@@ -1729,7 +1714,7 @@ static int manager_dispatch_sigchld(Manager *m) {
return r;
/* And now figure out the unit this belongs to */
- if (!(u = hashmap_get(m->watch_pids, UINT32_TO_PTR(si.si_pid))))
+ if (!(u = hashmap_get(m->watch_pids, LONG_TO_PTR(si.si_pid))))
u = cgroup_unit_by_pid(m, si.si_pid);
/* And now, we actually reap the zombie. */
@@ -1752,9 +1737,9 @@ static int manager_dispatch_sigchld(Manager *m) {
if (!u)
continue;
- log_debug("Child %llu belongs to %s", (long long unsigned) si.si_pid, u->meta.id);
+ log_debug("Child %lu belongs to %s", (long unsigned) si.si_pid, u->meta.id);
- hashmap_remove(m->watch_pids, UINT32_TO_PTR(si.si_pid));
+ hashmap_remove(m->watch_pids, LONG_TO_PTR(si.si_pid));
UNIT_VTABLE(u)->sigchld_event(u, si.si_pid, si.si_code, si.si_status);
}