[CRIU] [PATCH] ptrace: Print unseizrable task name on error

Cyrill Gorcunov gorcunov at openvz.org
Tue Mar 26 14:24:52 EDT 2013


Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---

Pavel, I guess this might help us in future, but not sure. Thus
feel free to ignore it.

 ptrace.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/ptrace.c b/ptrace.c
index fad2e54..0e1f956 100644
--- a/ptrace.c
+++ b/ptrace.c
@@ -36,6 +36,23 @@ int unseize_task(pid_t pid, int st)
 	return ptrace(PTRACE_DETACH, pid, NULL, NULL);
 }
 
+static char *task_comm(pid_t pid)
+{
+	static char comm[32];
+	size_t ret;
+	int fd;
+
+	fd = open_proc(pid, "/proc/%d/comm", pid);
+	if (fd >= 0) {
+		ret = read(fd, comm, sizeof(comm) - 1);
+		close(fd);
+		comm[ret < 0 ? 0 : ret - 1] = '\0';
+		return comm;
+	}
+
+	return NULL;
+}
+
 /*
  * This routine seizes task putting it into a special
  * state where we can manipulate the task via ptrace
@@ -72,8 +89,8 @@ int seize_task(pid_t pid, pid_t ppid, pid_t *pgid, pid_t *sid)
 
 	if (ret < 0) {
 		if (ps.state != 'Z') {
-			pr_err("Unseizeable non-zombie %d found, state %c, err %d/%d\n",
-					pid, ps.state, ret, ptrace_errno);
+			pr_err("Unseizeable non-zombie %d (%s) found, state %c, err %d/%d\n",
+					pid, task_comm(pid), ps.state, ret, ptrace_errno);
 			return -1;
 		}
 
-- 
1.8.1.4



More information about the CRIU mailing list