diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-07-13 19:58:35 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-07-13 19:59:28 +0200 |
commit | de07ab16c6b919cead26c9a5209a362127ff6142 (patch) | |
tree | 9b4d4f674ae5fa607fb8516be541d16dcca9e9c8 /src/logind-user.c | |
parent | a17204af0e950be7a5199db62ef400814e29aa3c (diff) |
loginctl: implement missing kill verb
Diffstat (limited to 'src/logind-user.c')
-rw-r--r-- | src/logind-user.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/logind-user.c b/src/logind-user.c index dacf148f78..1655a9a46b 100644 --- a/src/logind-user.c +++ b/src/logind-user.c @@ -325,7 +325,7 @@ static int user_shall_kill(User *u) { return strv_contains(u->manager->kill_only_users, u->name); } -static int user_kill_cgroup(User *u) { +static int user_terminate_cgroup(User *u) { int r; char **k; @@ -401,7 +401,7 @@ int user_stop(User *u) { r = k; /* Kill cgroup */ - k = user_kill_cgroup(u); + k = user_terminate_cgroup(u); if (k < 0) r = k; @@ -515,6 +515,31 @@ UserState user_get_state(User *u) { return USER_ONLINE; } +int user_kill(User *u, int signo) { + int r = 0, q; + Set *pid_set = NULL; + + assert(u); + + if (!u->cgroup_path) + return -ESRCH; + + pid_set = set_new(trivial_hash_func, trivial_compare_func); + if (!pid_set) + return -ENOMEM; + + q = cg_kill_recursive(SYSTEMD_CGROUP_CONTROLLER, u->cgroup_path, signo, false, true, false, pid_set); + if (q < 0) + if (q != -EAGAIN && q != -ESRCH && q != -ENOENT) + r = q; + +finish: + if (pid_set) + set_free(pid_set); + + return r; +} + static const char* const user_state_table[_USER_STATE_MAX] = { [USER_OFFLINE] = "offline", [USER_LINGERING] = "lingering", |