From: Andrew Morton <andrewm@uow.edu.au>
To: frey@cxau.zko.dec.com
Cc: "'Benjamin Herrenschmidt'" <benh@kernel.crashing.org>,
linux-kernel@vger.kernel.org
Subject: Re: kernel_thread vs. zombie
Date: Fri, 23 Mar 2001 02:13:01 +0000 [thread overview]
Message-ID: <3ABAB12D.CE7FA890@uow.edu.au> (raw)
In-Reply-To: <008901c0b33c$ab1f51a0$90600410@SCHLEPPDOWN>
Martin Frey wrote:
>
> >> - When started during boot (low PID (9)) It becomes a zombie
> >> - When started from a process that quits after sending the ioctl,
> >> it is correctly "garbage collected".
> >> - When started from a process that stays around, it becomes
> >> a zombie too
>
> >Take a look at kernel/kmod.c:call_usermodehelper(). Copy it.
> >
> >This will make your thread a child of keventd. This takes
> >care of things like chrootedness, uids, cwds, signal masks,
> >reaping children, open files, and all the other crud which
> >you can accidentally inherit from your caller.
> >
> So depending on the state of the caller daemonize() will not really
> put us into the background as we want.
Well, kernel_thread() will put you in the background, in the
sense that it creates an async thread. But you inherit
heaps of stuff from the parent. daemonize() cleans up
some of those things, but it can't clean up everything.
Kernel threads *need* to run in a well-understood and
sensible environment. We went through a lot of fun late
last year when there was a sudden proliferation of kernel
threads and quite a few things were subtly broken.
Things like kernel threads blocking signals because that's
what their user-space parent happened to do. Things like
user-space applications receiving a surprise SIGCHLD from
the kernel as a consequence of some system call which they
happened to have executed some while beforehand.
One approach would be to tromp through your task state setting
everything back where you want it. That's quite complex. Plus
there's the issue of who reaps the thread when it exits.
So I think it's reasonable to use keventd as `kinit', if you like.
Something which knows how to launch and reap kernel daemons, and
which provides a known environment to them.
A kernel API function (`kernel_daemon'?) which does all this
boilerplate is needed, I think.
-
next prev parent reply other threads:[~2001-03-23 2:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-03-22 11:49 kernel_thread vs. zombie Benjamin Herrenschmidt
2001-03-22 14:32 ` Martin Frey
2001-03-22 15:07 ` Benjamin Herrenschmidt
2001-03-22 17:21 ` Martin Frey
2001-03-22 18:47 ` Benjamin Herrenschmidt
2001-03-22 19:50 ` Martin Frey
2001-03-22 23:33 ` Benjamin Herrenschmidt
2001-03-23 0:04 ` Andrew Morton
2001-03-23 1:57 ` Martin Frey
2001-03-23 2:13 ` Andrew Morton [this message]
2001-03-23 8:06 ` Martin Frey
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=3ABAB12D.CE7FA890@uow.edu.au \
--to=andrewm@uow.edu.au \
--cc=benh@kernel.crashing.org \
--cc=frey@cxau.zko.dec.com \
--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