pstree: Add nspid() helper

To get pid in ns of current.

Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
Dmitry Safonov 2017-07-20 18:21:20 +03:00 committed by Andrei Vagin
parent 9ecab6c53f
commit ff1c5ca693
2 changed files with 6 additions and 6 deletions

View file

@ -785,7 +785,6 @@ static int prepare_sigactions(CoreEntry *core)
static int __collect_child_pids(struct pstree_item *p, int state, unsigned int *n)
{
int level = current->pid->level;
struct pstree_item *pi;
list_for_each_entry(pi, &p->children, sibling) {
@ -799,7 +798,7 @@ static int __collect_child_pids(struct pstree_item *p, int state, unsigned int *
return -1;
(*n)++;
*child = pi->pid->ns[level-1].virt;
*child = nspid(pi);
}
return 0;
@ -1099,11 +1098,10 @@ static unsigned long task_entries_pos;
static int wait_on_helpers_zombies(void)
{
int level = current->pid->level;
struct pstree_item *pi;
list_for_each_entry(pi, &current->children, sibling) {
pid_t pid = pi->pid->ns[level-1].virt;
pid_t pid = nspid(pi);
int status;
switch (pi->pid->state) {

View file

@ -33,6 +33,10 @@ struct pstree_item {
struct ns_id *pid_for_children_ns;
};
extern struct pstree_item *current;
#define nspid(item) (item->pid->ns[current->pid->level - 1].virt)
#define vpid(item) (item->pid->ns[0].virt)
#define vsid(item) (item->sid->ns[0].virt)
#define vpgid(item) (item->pgid->ns[0].virt)
@ -45,8 +49,6 @@ enum {
};
#define FDS_EVENT (1 << FDS_EVENT_BIT)
extern struct pstree_item *current;
struct rst_info;
/* See alloc_pstree_item() for details */
static inline struct rst_info *rsti(struct pstree_item *i)