[CRIU] [PATCH] seize: don't use wait4() to check whether or not a task is traced
Andrew Vagin
avagin at virtuozzo.com
Wed Nov 25 00:10:59 PST 2015
If a task is stopped, waitpid() will return its status, but
wait4() in seize_wait_task will hang forever, because a stopped
state is reported only once.
Reported-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
Cc: Andrey Ryabinin <aryabinin at virtuozzo.com>
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
seize.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/seize.c b/seize.c
index 11b5ad8..b6c9a67 100644
--- a/seize.c
+++ b/seize.c
@@ -102,14 +102,14 @@ static int seize_cgroup_tree(char *root_path, const char *state)
pid = atoi(path);
- /*
- * Here we are going to skip tasks which are already traced.
- * Ptraced tasks looks like children for us, so if
- * a task isn't ptraced yet, waitpid() will return a error.
- */
- ret = wait4(pid, NULL, __WALL | WNOHANG, NULL);
+ /* Here we are going to skip tasks which are already traced. */
+ ret = ptrace(PTRACE_INTERRUPT, pid, NULL, NULL);
if (ret == 0)
continue;
+ if (errno != ESRCH) {
+ pr_perror("Unexpected error");
+ return -1;
+ }
if (seize_catch_task(pid) && state == frozen) {
char buf[] = "/proc/XXXXXXXXXX/exe";
--
2.4.3
More information about the CRIU
mailing list