Using dlopen will allow you to perform the fork() prior to running theBut I don't even need that: I init it manually, there
library's initialization code.
As I said, I can't comment on the patch - I'm not familiar with thatYes, that's true, but treat that as my personal tour to the
part of the kernel, so I don't know what kind of races may be lurking.
But based on Oleg's comments, it seems clear to me that implementing
your PR_DETACH is quite a complex thing to be doing.
It is true thatYes, I share that concerns too. And it is very unlikely that
being able to daemonize() without losing threads would be a nice thing
to have; I just have my doubts that it's worth the potential bugs that
such a change might introduce, when it's only needed in a somewhat
rare case, and when perfectly good workarounds exist in userspace.