summaryrefslogtreecommitdiff
path: root/src/cgroup-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-03-03 23:55:30 +0100
committerLennart Poettering <lennart@poettering.net>2011-03-03 23:55:30 +0100
commit430c18ed7f576fd9041b0a02e7c4210bdd020a25 (patch)
tree0ea2aa6c3d7c434c1c8b5dd2c91ca7b54a7771c4 /src/cgroup-util.c
parent2b590e135f53a1bd3e771bdc555f7bf28c4cd232 (diff)
kill: always send SIGCONT after SIGTERM
When we kill a process to terminate it make sure to send SIGCONT to ensure it is unpaused and processes the signal.
Diffstat (limited to 'src/cgroup-util.c')
-rw-r--r--src/cgroup-util.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/cgroup-util.c b/src/cgroup-util.c
index b68b9ad3a3..055c906106 100644
--- a/src/cgroup-util.c
+++ b/src/cgroup-util.c
@@ -166,7 +166,7 @@ int cg_rmdir(const char *controller, const char *path) {
return r < 0 ? -errno : 0;
}
-int cg_kill(const char *controller, const char *path, int sig, bool ignore_self, Set *s) {
+int cg_kill(const char *controller, const char *path, int sig, bool sigcont, bool ignore_self, Set *s) {
bool done = false;
int r, ret = 0;
pid_t my_pid;
@@ -211,8 +211,13 @@ int cg_kill(const char *controller, const char *path, int sig, bool ignore_self,
if (kill(pid, sig) < 0) {
if (ret >= 0 && errno != ESRCH)
ret = -errno;
- } else if (ret == 0)
+ } else if (ret == 0) {
+
+ if (sigcont)
+ kill(pid, SIGCONT);
+
ret = 1;
+ }
done = false;
@@ -250,7 +255,7 @@ finish:
return ret;
}
-int cg_kill_recursive(const char *controller, const char *path, int sig, bool ignore_self, bool rem, Set *s) {
+int cg_kill_recursive(const char *controller, const char *path, int sig, bool sigcont, bool ignore_self, bool rem, Set *s) {
int r, ret = 0;
DIR *d = NULL;
char *fn;
@@ -264,7 +269,7 @@ int cg_kill_recursive(const char *controller, const char *path, int sig, bool ig
if (!(s = allocated_set = set_new(trivial_hash_func, trivial_compare_func)))
return -ENOMEM;
- ret = cg_kill(controller, path, sig, ignore_self, s);
+ ret = cg_kill(controller, path, sig, sigcont, ignore_self, s);
if ((r = cg_enumerate_subgroups(controller, path, &d)) < 0) {
if (ret >= 0 && r != -ENOENT)
@@ -286,7 +291,7 @@ int cg_kill_recursive(const char *controller, const char *path, int sig, bool ig
goto finish;
}
- r = cg_kill_recursive(controller, p, sig, ignore_self, rem, s);
+ r = cg_kill_recursive(controller, p, sig, sigcont, ignore_self, rem, s);
free(p);
if (r != 0 && ret >= 0)
@@ -336,7 +341,7 @@ int cg_kill_recursive_and_wait(const char *controller, const char *path, bool re
else
sig = 0;
- if ((r = cg_kill_recursive(controller, path, sig, true, rem, NULL)) <= 0)
+ if ((r = cg_kill_recursive(controller, path, sig, true, true, rem, NULL)) <= 0)
return r;
usleep(200 * USEC_PER_MSEC);