apr-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 43329] - apr_proc_create behavior change
Date Sat, 08 Sep 2007 23:14:48 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43329>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43329





------- Additional Comments From wrowe@apache.org  2007-09-08 16:14 -------
Here's one proposal;

if we added a new ***platform independent*** flag to apr_procattr_XXX(?) that
would close-on-exec any undesired (null) child handles on unix, while for win32
would set the StdHandle value to INVALID_HANDLE_VALUE, I could accept that this
would be very useful.

It's a new-flag because the side effects of changing the unix assumption result
in a app that opens a file, lets say it lands in fd2, and then the programmer
discovers there is additional garbage in their file emitted from some library
which logged some error condition to stderr.  On windows, some process such as
cmd.exe would mysteriously fail to start if they didn't exist in a console,
e.g. when cmd.exe is run in a service context.  Both bugs can be hard to track
down for the typical user.

So it appears that APR 1.2.11 behavior is correct, but confusing to libfcgid
and a handful of other apps that have exploited the existing error.  We can
work around those limited cases.

The patch on Win32 might look like this;

             si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
-            if (attr->child_in && attr->child_in->filehand)
+            if ((attr->child_in && attr->child_in->filehand)
+                   || (attr->flags & APR_NO_DEFAULT_CHILD_STDFILES))
             {
                 if (GetHandleInformation(si.hStdInput,
                                          &stdin_reset)
                         && (stdin_reset &= HANDLE_FLAG_INHERIT))
                     SetHandleInformation(si.hStdInput,
                                          HANDLE_FLAG_INHERIT, 0);
                 si.hStdInput = INVALID_HANDLE_VALUE;
             }
+            if ((attr->child_in && attr->child_in->filehand)) {
                 si.hStdInput = attr->child_in->filehand;
                 SetHandleInformation(si.hStdInput, HANDLE_FLAG_INHERIT,
                                                    HANDLE_FLAG_INHERIT);
             }
 

while on Unix, it would look something closer to

         if (attr->child_in) {
             apr_file_close(attr->parent_in);
             dup2(attr->child_in->filedes, STDIN_FILENO);
             apr_file_close(attr->child_in);
         }
+        else if (attr->flags & APR_NO_DEFAULT_CHILD_STDFILES) 
+            close(STDIN_FILENO);

Does this sound like a solution that would restore mod_fcgid without requiring
extra apr or libfcgid patches, while also permitting cross-platform behavior?

If you agree it's a solution, we can propose this to the dev@apr list and
pick up the discussion there.


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


Mime
View raw message