www-apache-bugdb mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jesse Pelton <...@pkc.com>
Subject os-windows/1834: Cannot write to stdout with WriteFile() in CGI-bin executables
Date Wed, 18 Feb 1998 19:03:28 GMT

>Number:         1834
>Category:       os-windows
>Synopsis:       Cannot write to stdout with WriteFile() in CGI-bin executables
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    apache
>State:          open
>Class:          sw-bug
>Submitter-Id:   apache
>Arrival-Date:   Wed Feb 18 11:10:00 PST 1998
>Originator:     jsp@pkc.com
>Release:        1.3b3
Win NT 4.0 SP3
MSVC 5.0
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), ...) fails in CGI-bin executables.
GetLastError() returns ERROR_INVALID_HANDLE.  Replacing the call to WriteFile()
with an equivalent fwrite() works.

My guess is that the dup() and dup2() functions used in spawn_child_err_core()
are not completely compatible with the Win32 SDK functions, though
Microsoft claims, "All run-time library routines included with [MSVC] are
compatible with the Win32 API."
In a working C/C++ CGI-bin program, replace calls to fwrite(), fputs(), etc,
with calls to WriteFile().
I haven't tested this, but my guess is that using the Win32 APIs (CreatePipe(),
GetStdHandle(), SetStdHandle(), DuplicateHandle(), CloseHandle()) in
spawn_child_err_core() would fix the problem.  (See the MSDN article titled
"Creating a Child Process with Redirected Input and Output" for sample code.)
The obvious question is, would this enable WriteFile(), only to disable
[In order for any reply to be added to the PR database, ]
[you need to include <apbugs@Apache.Org> in the Cc line ]
[and leave the subject line UNCHANGED.  This is not done]
[automatically because of the potential for mail loops. ]

View raw message