lkml.org 
[lkml]   [2011]   [Jun]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    SubjectRe: [PATCH] Introduce ActivePid: in /proc/self/status (v2, was Vpid:)
    From
    Date
    On Thu, 2011-06-16 at 08:07 -0700, Eric W. Biederman wrote:
    > > Finally, we thought that the 'ActivePid' information was interesting
    > > enough to be exposed in /proc and was solving the case we're facing
    > > rather easily with some framework (cgroups) in user space.
    >
    > The pid number by which a process knows itself doesn't seem
    > unreasonable. I'm not totally
    >
    > After having a second look at the code in proc we already have
    > a reference to the struct pid we want to print. So simply
    > printing
    > pid->numbers[pid->level].nr
    > seems reasonable, and race free.
    >
    > Alternatively that could be written.
    > pid_nr_ns(pid, ns_of_pid(pid));
    >
    > Eric

    So we end up with the following, since pid is valid:

    diff --git a/fs/proc/array.c b/fs/proc/array.c
    index 5e4f776..b7316cc 100644
    --- a/fs/proc/array.c
    +++ b/fs/proc/array.c
    @@ -183,12 +183,14 @@ static inline void task_state(struct seq_file *m,
    struct pid_namespace *ns,
    "Pid:\t%d\n"
    "PPid:\t%d\n"
    "TracerPid:\t%d\n"
    + "ActivePid:\t%d\n"
    "Uid:\t%d\t%d\t%d\t%d\n"
    "Gid:\t%d\t%d\t%d\t%d\n",
    get_task_state(p),
    task_tgid_nr_ns(p, ns),
    pid_nr_ns(pid, ns),
    ppid, tpid,
    + pid_nr_ns(pid, ns_of_pid(pid)),
    cred->uid, cred->euid, cred->suid, cred->fsuid,
    cred->gid, cred->egid, cred->sgid, cred->fsgid);

    --
    Gregory Kurz gkurz@fr.ibm.com
    Software Engineer @ IBM/Meiosys http://www.ibm.com
    Tel +33 (0)534 638 479 Fax +33 (0)561 400 420
    "Anarchy is about taking complete responsibility for yourself."
    Alan Moore.



    \
     
     \ /
      Last update: 2011-06-16 17:35    [W:3.747 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site