Quote Originally Posted by Valery Reznic View Post
Did child need those or any other file descriptors from parents at all ?

If not - and assuming your are using Linux (who use something else for servers anyway
you can instead of fork use clone with flag CLONE_FILES turn off
In this case parent and child will not share file descriptors.

If child really uses some file descriptors from parent, then turning of CLONE_FILES is not an option.
In this case you can write small shared libraries and run your child process with this libraries LD_PRELOADed.

Shared library should implement 'close' function. Those function should do nothing for
network connection and database connection file descriptors and behaves like original close for any other
the child has absolutely no need of the socket or the db connection; however, the sticky part of this whole thing is that the parent communicates with the child through a pipe via popen(), so at least SOME file descriptors need to be cloned. unfortunately, I can't choose which ones, so it's all or nothing.

in any case, I've come up with a pretty workable solution to this problem. I'm going to re-write the credit card processor as a standalone server that listens on a unix-domain socket (AF_UNIX) and then I won't have to worry about it. the two processes will be unrelated, and therefore, share no file descriptors, and my problem will magically disappear.