Messages in this thread | | | Date | Tue, 19 Apr 2011 19:08:49 +0400 | From | Stas Sergeev <> | Subject | Re: [path][rfc] add PR_DETACH prctl command [3/3] |
| |
19.04.2011 18:58, Alan Cox wrote: >> The attached patch implements the PR_DETACH prctl >> command. It detaches the entire process group from >> its parent, allowing the parent to still read the detach >> code with normal wait(). If the process then exits, the >> notification of the new parent is delayed till the old parent >> does either wait() to read the detach code, or exits. > What is the use case for this and why won't existing process group > interfaces do the job ? The use case is to daemonize the process with threads. You first need to detach it from its parent, then use TIOCNOTTY ioctl to detach from the tty (TIOCNOTTY_GRP doesn't seem to exist too, though, but might be easy to implement). There are a few workarounds to that that I am aware of, but what exactly interfaces do you have in mind? I have found nothing that allows to do the same without a workarounds like this: https://lkml.org/lkml/2011/4/8/278 The current way of detaching, which is a fork/exit combo, loses all threads, so, when you call daemon() and you had threads, you are a toast.
| |