Commit 54862513 authored by Pavel Emelyanov's avatar Pavel Emelyanov

pstree: Introduce task_alive() helper

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent ab1be206
...@@ -643,11 +643,8 @@ static int prepare_sigactions(void) ...@@ -643,11 +643,8 @@ static int prepare_sigactions(void)
int sig, rst = 0; int sig, rst = 0;
int ret = 0; int ret = 0;
switch (current->state) { if (!task_alive(current))
case TASK_HELPER:
case TASK_DEAD:
return 0; return 0;
}
pr_info("Restore sigacts for %d\n", pid); pr_info("Restore sigacts for %d\n", pid);
...@@ -1474,10 +1471,7 @@ static int attach_to_tasks(bool root_seized) ...@@ -1474,10 +1471,7 @@ static int attach_to_tasks(bool root_seized)
pid_t pid = item->pid.real; pid_t pid = item->pid.real;
int status, i; int status, i;
if (item->state == TASK_DEAD) if (!task_alive(item))
continue;
if (item->state == TASK_HELPER)
continue; continue;
if (parse_threads(item->pid.real, &item->threads, &item->nr_threads)) if (parse_threads(item->pid.real, &item->threads, &item->nr_threads))
...@@ -1527,10 +1521,7 @@ static void finalize_restore(int status) ...@@ -1527,10 +1521,7 @@ static void finalize_restore(int status)
struct parasite_ctl *ctl; struct parasite_ctl *ctl;
int i; int i;
if (item->state == TASK_DEAD) if (!task_alive(item))
continue;
if (item->state == TASK_HELPER)
continue; continue;
if (status < 0) if (status < 0)
......
...@@ -40,6 +40,11 @@ static inline int shared_fdtable(struct pstree_item *item) { ...@@ -40,6 +40,11 @@ static inline int shared_fdtable(struct pstree_item *item) {
item->ids->files_id == item->parent->ids->files_id); 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 void free_pstree(struct pstree_item *root_item);
extern struct pstree_item *__alloc_pstree_item(bool rst); extern struct pstree_item *__alloc_pstree_item(bool rst);
#define alloc_pstree_item() __alloc_pstree_item(false) #define alloc_pstree_item() __alloc_pstree_item(false)
......
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