apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <...@covalent.net>
Subject Re: Inheritable APR handles.
Date Sun, 15 Jul 2001 01:15:03 GMT
On Sat, 14 Jul 2001, Justin Erenkrantz wrote:

> On Sat, Jul 14, 2001 at 04:50:52PM -0700, rbb@covalent.net wrote:
> >
> > This patch begins to implement the inherit flag that Will Rowe was talking
> > about yesterday on Unix.  Basically, every APR type that can be inherited
> > would specify at creation time whether it should be created to be
> > inherited or not.  Then, there are two functions, apr_foo_set_inherit and
> > apr_foo_unset_inherit that flip the flag.  This will finally get us
> > registering child cleanups correctly.  I have created a new APR header,
> > apr_inherit.h, which implements some macros to create the
> > apr_foo_(un)set_inherit functions for Unix, I have copied that inline in
> > this message.
> >
> > Unless I hear objections, I will commit this code either tomorrow or
> > Monday.  Once it is committed, I will use it to fix a couple of bugs in
> > Apache.  :-)
> What's the use case for this?  What are the bugs that we're seeing?
> Is this relating to CGI?  (I know Win32 has some funny things related to
> inheriting listeners from dead parents.)

On ALL operating systems we are keeping some things inherited that
shouldn't be.  There are open bugs that the piped log processes are
keeping the sockets open, because there is no child_cleanup registered.
The reality is that different platforms behave differently when it comes
to inheriting open descriptors.  Unix inherits everything be default,
Windows inherits nothing.

> You have a pipe (or some other type, say socket) that is opened by the
> parent process (like the POD).  When you do the fork, the open
> descriptors will be passed to the child (per semantics of fork).  But,
> now we want to make sure that certain file descriptors are closed when
> the child starts?


> ---
> #define APR_INHERIT    4096        /* Create the file inheritable by the child
>                                       process. fork()ed implementations
>                                       automatically register a child cleanup
>                                       in the _absence_ of this flag. */
> ---
> What would be the default - inheritied or non-inherited?  It'd seem
> that the default should be inherited.  That follows the typical

The default would be inherited, although only Files would get that
default.  Every other APR descriptor type (socket for right now, IPC
should come sooner or later) would need to have a flag passed in, because
they don't have a flag praameter already.

> convention.  If we must explicitly specify APR_INHERIT, that now runs us
> contrary to typical programming practices (in Unix land).  And, that's
> what most people would expect (descriptors are inhreited), but that
> doesn't seem to be the case - the default looks to be non-inherited.
> IMHO, the exceptions are the cases when you want it to be *not* inherited.

If the file implementation that Bill provided defaults to non-inherited,
then that is wrong, but we MUST have the ability to set files and sockets
as inherited or not at creation time, and to toggle that switch as needed
while running the program.

Ryan Bloom                        	rbb@apache.org
Covalent Technologies			rbb@covalent.net

View raw message