[CRIU] [PATCH 1/3] proc: parse sigpnd and shdpnd separatly

Andrey Vagin avagin at openvz.org
Wed Nov 25 08:50:09 PST 2015


From: Andrew Vagin <avagin at virtuozzo.com>

We found that we want to know whether SIGSTOP is queue
in both or is in one of this queues.

Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 include/proc_parse.h |  1 +
 proc_parse.c         | 17 ++++++++++++++---
 ptrace.c             |  2 +-
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/include/proc_parse.h b/include/proc_parse.h
index 123f5db..e45d93f 100644
--- a/include/proc_parse.h
+++ b/include/proc_parse.h
@@ -93,6 +93,7 @@ struct proc_status_creds {
 	char			state;
 	int			ppid;
 	unsigned long long	sigpnd;
+	unsigned long long	shdpnd;
 
 	int			seccomp_mode;
 	u32			last_filter;
diff --git a/proc_parse.c b/proc_parse.c
index e39129d..c479b0f 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -767,11 +767,12 @@ int parse_pid_status(pid_t pid, struct proc_status_creds *cr)
 	}
 
 	cr->sigpnd = 0;
+	cr->shdpnd = 0;
 
 	if (bfdopenr(&f))
 		return -1;
 
-	while (done < 11) {
+	while (done < 12) {
 		str = breadline(&f);
 		if (str == NULL)
 			break;
@@ -851,7 +852,17 @@ int parse_pid_status(pid_t pid, struct proc_status_creds *cr)
 			continue;
 		}
 
-		if (!strncmp(str, "SigPnd:", 7) || !strncmp(str, "ShdPnd:", 7)) {
+		if (!strncmp(str, "ShdPnd:", 7)) {
+			unsigned long long sigpnd;
+
+			if (sscanf(str + 7, "%llx", &sigpnd) != 1)
+				goto err_parse;
+			cr->shdpnd |= sigpnd;
+
+			done++;
+			continue;
+		}
+		if (!strncmp(str, "SigPnd:", 7)) {
 			unsigned long long sigpnd;
 
 			if (sscanf(str + 7, "%llx", &sigpnd) != 1)
@@ -864,7 +875,7 @@ int parse_pid_status(pid_t pid, struct proc_status_creds *cr)
 	}
 
 	/* seccomp is optional */
-	if (done >= 10 || (done == 9 && !parsed_seccomp))
+	if (done >= 11 || (done == 10 && !parsed_seccomp))
 		ret = 0;
 
 err_parse:
diff --git a/ptrace.c b/ptrace.c
index b0aae2d..59c5955 100644
--- a/ptrace.c
+++ b/ptrace.c
@@ -204,7 +204,7 @@ try_again:
 	if (cr.seccomp_mode != SECCOMP_MODE_DISABLED && suspend_seccomp(pid) < 0)
 		goto err;
 
-	if (cr.sigpnd & (1 << (SIGSTOP - 1)) || si.si_signo == SIGSTOP) {
+	if ((cr.sigpnd | cr.shdpnd) & (1 << (SIGSTOP - 1)) || si.si_signo == SIGSTOP) {
 		/*
 		 * 1) SIGSTOP is queued, but isn't handled yet:
 		 * SGISTOP can't be blocked, so we need to wait when the kernel
-- 
2.4.3



More information about the CRIU mailing list