[CRIU] [PATCH 1/2] pstree: Introduce task_alive() helper

Pavel Emelyanov xemul at parallels.com
Thu Aug 7 02:30:54 PDT 2014


Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 cr-restore.c     | 15 +++------------
 include/pstree.h |  5 +++++
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/cr-restore.c b/cr-restore.c
index 1b538e1..38ee91c 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -641,11 +641,8 @@ static int prepare_sigactions(void)
 	int sig, rst = 0;
 	int ret = 0;
 
-	switch (current->state) {
-	case TASK_HELPER:
-	case TASK_DEAD:
+	if (!task_alive(current))
 		return 0;
-	}
 
 	pr_info("Restore sigacts for %d\n", pid);
 
@@ -1464,10 +1461,7 @@ static int attach_to_tasks(bool root_seized)
 		pid_t pid = item->pid.real;
 		int status, i;
 
-		if (item->state == TASK_DEAD)
-			continue;
-
-		if (item->state == TASK_HELPER)
+		if (!task_alive(item))
 			continue;
 
 		if (parse_threads(item->pid.real, &item->threads, &item->nr_threads))
@@ -1517,10 +1511,7 @@ static void finalize_restore(int status)
 		struct parasite_ctl *ctl;
 		int i;
 
-		if (item->state == TASK_DEAD)
-			continue;
-
-		if (item->state == TASK_HELPER)
+		if (!task_alive(item))
 			continue;
 
 		if (status  < 0)
diff --git a/include/pstree.h b/include/pstree.h
index dd04708..c361e18 100644
--- a/include/pstree.h
+++ b/include/pstree.h
@@ -40,6 +40,11 @@ static inline int shared_fdtable(struct pstree_item *item) {
 		item->ids->files_id == item->parent->ids->files_id);
 }
 
+static inline bool task_alive(struct pstree_item *i)
+{
+	return (i->state == TASK_ALIVE) || (i->state == TASK_STOPPED);
+}
+
 extern void free_pstree(struct pstree_item *root_item);
 extern struct pstree_item *__alloc_pstree_item(bool rst);
 #define alloc_pstree_item() __alloc_pstree_item(false)
-- 
1.8.4.2




More information about the CRIU mailing list