Commit 7828bbc3 authored by Andrew Vagin's avatar Andrew Vagin Committed by Pavel Emelyanov

seize: don't use wait4() to check whether or not a task is traced

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.

v2: don't like a file object
Reported-by: 's avatarAndrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 708e2b37
...@@ -102,14 +102,15 @@ static int seize_cgroup_tree(char *root_path, const char *state) ...@@ -102,14 +102,15 @@ static int seize_cgroup_tree(char *root_path, const char *state)
pid = atoi(path); pid = atoi(path);
/* /* Here we are going to skip tasks which are already traced. */
* Here we are going to skip tasks which are already traced. ret = ptrace(PTRACE_INTERRUPT, pid, NULL, NULL);
* 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);
if (ret == 0) if (ret == 0)
continue; continue;
if (errno != ESRCH) {
pr_perror("Unexpected error");
fclose(f);
return -1;
}
if (seize_catch_task(pid) && state == frozen) { if (seize_catch_task(pid) && state == frozen) {
char buf[] = "/proc/XXXXXXXXXX/exe"; char buf[] = "/proc/XXXXXXXXXX/exe";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment