apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter N. Lundblad" <pe...@famlundblad.se>
Subject Re: Pipe inheritance
Date Wed, 18 Jan 2006 19:20:50 GMT
On Wed, 18 Jan 2006, William A. Rowe, Jr. wrote:

> > + * @remark The returned file descriptors will be inherited by child processes.
> > + * This can be changed using apr_file_inherit_unset().
> >   */
> >  APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in,
> >                                                 apr_file_t **out,
>
> Suppose we should further observe that it's strongly recommended that only
> one side of a given pipe should remain inherited, and the server's side of
> all pipes should be immediately apr_file_inherit_unset() upon creation?
>
Maybe, but I wasn't sure how much IPC programming we wanted to teach the
reader of this reference guide...

> FYI this is one of the -race- conditions observed on httpd with cgi.  It's
> quite possible on an event/worker threaded server that a second thread has
> invoked apr_file_pipe_create, not flagged the server side as uninherited,
> while the first thread is fork()ing for exec.  That other daemon on thread
> one holds open both ends of the pipe forever, resulting in no EOF.
>
Ugh! Is there a way round this without serializing pipe creating/fork?

When I think about this, it seems like there is a race in every file open
situation, since you can't install the cleanup handler before the file is
opened. Or, you maybe can, but it doesn't happen in the current code. Or
do I miss something now?

Thanks,
//Peter

Mime
View raw message