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.
-
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/