From: Oleg Nesterov <oleg@redhat.com>
To: Karl Pickett <kjp@ci.uchicago.edu>
Cc: linux-kernel@vger.kernel.org, kay.sievers@vrfy.org,
Lennart Poettering <lennart@poettering.net>
Subject: Re: Is prctl(PR_SET_CHILD_SUBREAPER) going to break my code which checks getppid == 1?
Date: Fri, 30 Mar 2012 19:14:30 +0200 [thread overview]
Message-ID: <20120330171430.GA5865@redhat.com> (raw)
In-Reply-To: <376EB22C-893C-4AF8-81DC-3A7687B1AE1B@ci.uchicago.edu>
On 03/30, Karl Pickett wrote:
>
> On Mar 30, 2012, at 7:44 AM, Oleg Nesterov wrote:
>
> > Perhaps you can do something like
> >
> > ppid_for_child = getpid();
> >
> > if (!fork()) {
> > // Child
> > prctl(PR_SET_PDEATHSIG);
> > if (getppid() != ppid_for_child)
> > return;
> > ...
> > }
>
> There are two problems with that. 1., I don't think TCL/TK lets me access
> the parent pre-fork env like that - all I can change is the execed code.
Can't comment this, I do not know tcl/tk
> 2., That has a clear race with pid wrap around.
Not really. This ppid_for_child can be re-used, yes. But the new process
which gets this pid can't become the parent, getppid() can't return this
number.
Btw, PR_SET_PDEATHSIG + getppid() check is racy anyway (with or without
PR_SET_CHILD_SUBREAPER), it can race with reparenting. But the window is
tiny and the problem is purely theoretical I think.
> You really need a
> prctl(PR_DID_MY_REAL_PARENT_DIE) function to be safe.
Oh, I don't know. Sure, PR_SET_CHILD_SUBREAPER can confuse the child.
Just suppose it does daemonize() + assert(getppid() == 1). But this
is not the kernel problem.
Oleg.
prev parent reply other threads:[~2012-03-30 17:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-29 20:12 Karl Pickett
2012-03-30 12:44 ` Oleg Nesterov
2012-03-30 13:17 ` Karl Pickett
2012-03-30 13:26 ` Karl Pickett
2012-03-30 17:14 ` Oleg Nesterov [this message]
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=20120330171430.GA5865@redhat.com \
--to=oleg@redhat.com \
--cc=kay.sievers@vrfy.org \
--cc=kjp@ci.uchicago.edu \
--cc=lennart@poettering.net \
--cc=linux-kernel@vger.kernel.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
Powered by JetHome