diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-01-31 23:51:16 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-01-31 23:51:39 +0100 |
commit | 9b221b63e5cc62439b32bb487775856a78c6015a (patch) | |
tree | b905fc9aed3558038ab61db464338548b0ec6d5a /src/login/logind-session.c | |
parent | 7e64c73a93cdcc7068280f3e3ba8adbd6c6f8f84 (diff) |
logind: if we have to stop a session, kill at least its leader
Diffstat (limited to 'src/login/logind-session.c')
-rw-r--r-- | src/login/logind-session.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/login/logind-session.c b/src/login/logind-session.c index 5ea7e260a7..c0d9532968 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -601,6 +601,23 @@ static int session_terminate_cgroup(Session *s) { log_error("Failed to kill session cgroup: %s", strerror(-r)); } else { + if (s->leader > 0) { + Session *t; + + /* We still send a HUP to the leader process, + * even if we are not supposed to kill the + * whole cgroup. But let's first check the + * leader still exists and belongs to our + * session... */ + + r = manager_get_session_by_pid(s->manager, s->leader, &t); + if (r > 0 && t == s) { + kill(s->leader, SIGTERM); /* for normal processes */ + kill(s->leader, SIGHUP); /* for shells */ + kill(s->leader, SIGCONT); /* in case they are stopped */ + } + } + r = cg_is_empty_recursive(SYSTEMD_CGROUP_CONTROLLER, s->cgroup_path, true); if (r < 0) log_error("Failed to check session cgroup: %s", strerror(-r)); @@ -608,8 +625,7 @@ static int session_terminate_cgroup(Session *s) { r = cg_delete(SYSTEMD_CGROUP_CONTROLLER, s->cgroup_path); if (r < 0) log_error("Failed to delete session cgroup: %s", strerror(-r)); - } else - r = -EBUSY; + } } STRV_FOREACH(k, s->user->manager->controllers) @@ -620,7 +636,7 @@ static int session_terminate_cgroup(Session *s) { free(s->cgroup_path); s->cgroup_path = NULL; - return r; + return 0; } static int session_unlink_x11_socket(Session *s) { |