Commit b08836cc authored by Qiang Huang's avatar Qiang Huang Committed by Pavel Emelyanov

pstree: add a function to check if a task is in pstree

Sometimes, when we parse some global info files, we can only care about
tasks which are taken into dump(such as file locks), which means their
pids are in the pstree.
So a function like this would be help.
Signed-off-by: 's avatarQiang Huang <h.huangqiang@huawei.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent de54cd43
......@@ -68,6 +68,7 @@ extern bool restore_before_setsid(struct pstree_item *child);
extern int prepare_pstree(void);
extern int dump_pstree(struct pstree_item *root_item);
extern bool pid_in_pstree(pid_t pid);
struct task_entries;
extern struct task_entries *task_entries;
......
......@@ -502,3 +502,15 @@ bool restore_before_setsid(struct pstree_item *child)
return false;
}
bool pid_in_pstree(pid_t pid)
{
struct pstree_item *item;
for_each_pstree_item(item) {
if (item->pid.real == pid)
return true;
}
return 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