From: Mike Heffner <mikeh-ql8fK+M3D0TQT0dZR+AlfA@public.gmane.org>
To: Daniel Lezcano <daniel.lezcano-GANU6spQydw@public.gmane.org>
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: Re: Mapping PIDs from parent->child namespaces
Date: Tue, 04 Jan 2011 14:57:16 -0500 [thread overview]
Message-ID: <4D237B9C.5060007@fesnel.com> (raw)
In-Reply-To: <4D23451B.6060807-GANU6spQydw@public.gmane.org>
On 01/04/2011 11:04 AM, Daniel Lezcano wrote:
> On 01/04/2011 12:02 AM, Mike Heffner wrote:
>> Hi,
>>
>> Is it possible for a process running in a parent PID namespace to map
>> the PID of a process running in a child's namespace from the
>> parent->child's namespace? For example, if I span the process "myproc"
>> with CLONE_NEWPID then a call to getpid() inside myproc will return "1"
>> whereas in the parent's namespace that process could actually be PID
>> "23495". I'd like to be able to know that 23495 maps to 1 in the new NS.
>> Obviously, just mapping the first PID is straightforward since I can
>> just look at the result of clone(). However, mapping the PIDs of
>> processes subsequently forked from "myproc" -- in this example -- I
>> haven't been able to figure out.
>
> AFAIK, it is not possible.
>
> That would be very nice to show the pid<-> vpid association.
>
> The procfs is a good candidate to show these informations.
>
> That would makes sense to show the content of /proc/<pid>/status with
> the pid relatively to the namespace.
>
> Let me give an example:
>
> Assuming the process '1234' creates a new pid namespace, and the child
> which is '1' in the new namespace has the real pid '4321'. This one
> mounts its /proc.
>
> If the process '1234' looks at /proc/4321/root/proc/1/status, it sees:
>
> ...
> Tgid: 1
> Pid: 1
> PPid: 0
> ...
>
>
> It could be:
>
> ...
> Tgid: 4321
> Pid: 4321
> PPid: 1234
> ...
>
> as the file is inspected from the parent namespace. Of course, if the
> file is looked from the child namespace context, we will see '1', '1'
> and '0'.
>
> I suppose the patch in the kernel should very small also.
>
> Thoughts ?
Would that mean that finding the pid->vpid association for a real PID X
requires checking all files /proc/<X>/root/proc/<Y>/status where Y is
all vpids until you find the one where Pid == X? It would be nice to
have a have a way to check a single file for the association where vpid
is not known beforehand -- unless I'm misunderstanding your solution.
Cheers,
Mike
next prev parent reply other threads:[~2011-01-04 19:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-03 23:02 Mapping PIDs from parent->child namespaces Mike Heffner
[not found] ` <4D225579.6030106-ql8fK+M3D0TQT0dZR+AlfA@public.gmane.org>
2011-01-04 16:04 ` Daniel Lezcano
[not found] ` <4D23451B.6060807-GANU6spQydw@public.gmane.org>
2011-01-04 16:44 ` Cedric Le Goater
[not found] ` <4D234E77.6000605-GANU6spQydw@public.gmane.org>
2011-01-04 20:17 ` Mike Heffner
[not found] ` <4D23806C.5040806-ql8fK+M3D0TQT0dZR+AlfA@public.gmane.org>
2011-01-04 20:49 ` Serge Hallyn
2011-01-05 13:50 ` Cedric Le Goater
[not found] ` <4D24773F.8050800-GANU6spQydw@public.gmane.org>
2011-01-05 13:54 ` Cedric Le Goater
2011-01-04 22:02 ` Daniel Lezcano
2011-01-04 19:57 ` Mike Heffner [this message]
[not found] ` <4D237B9C.5060007-ql8fK+M3D0TQT0dZR+AlfA@public.gmane.org>
2011-01-04 22:13 ` Daniel Lezcano
[not found] ` <4D239B72.4000103-GANU6spQydw@public.gmane.org>
2011-01-05 4:50 ` Mike Heffner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D237B9C.5060007@fesnel.com \
--to=mikeh-ql8fk+m3d0tqt0dzr+alfa@public.gmane.org \
--cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=daniel.lezcano-GANU6spQydw@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox