ID: 40758 Comment by: jostb2345 at yahoo dot de Reported By: jostb2345 at yahoo dot com Status: Feedback Bug Type: CGI related Operating System: Windows (all versions) PHP Version: 5.2.1 Assigned To: dmitry New Comment:
# include <windows.h> # include <winsock2.h> # define close closesocket term() { printf("err:%d", (GetLastError())); exit(1); } struct sockaddr_in saddr; main() { SOCKET listen_handle; SOCKADDR_IN saServer; char *cmd = "php-cgi.exe"; STARTUPINFO su_info; SECURITY_ATTRIBUTES sa = { 0 }; WORD wVersionRequested = MAKEWORD(1,1); WSADATA wsaData; int n = WSAStartup(wVersionRequested, &wsaData); if (wsaData.wVersion != wVersionRequested) term(); listen_handle = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); saServer.sin_family = AF_INET; saServer.sin_addr.s_addr = INADDR_ANY; saServer.sin_port = htons(9667); n = bind(listen_handle, (LPSOCKADDR)&saServer, sizeof(struct sockaddr)); if (n == SOCKET_ERROR) term(); n = listen(listen_handle, 20); if (n == SOCKET_ERROR) term(); ZeroMemory(&su_info, sizeof(STARTUPINFO)); su_info.cb = sizeof(STARTUPINFO); su_info.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; su_info.wShowWindow = SW_HIDE; su_info.hStdInput = listen_handle; su_info.hStdError = INVALID_HANDLE_VALUE; su_info.hStdOutput = INVALID_HANDLE_VALUE; SetHandleInformation(su_info.hStdInput, HANDLE_FLAG_INHERIT, TRUE); PROCESS_INFORMATION p; if(CreateProcess(NULL, cmd, NULL, NULL, 1, 0, NULL, NULL, &su_info, &p)) { CloseHandle(p.hThread); closesocket(listen_handle); } else { term(); } if( WaitForSingleObject(p.hProcess, INFINITE) == WAIT_FAILED ){ term(); } WSACleanup(); } Previous Comments: ------------------------------------------------------------------------ [2007-03-09 13:36:15] [EMAIL PROTECTED] I don't see any difference with old code. See OS_IsFcgi() and OS_LibInit(). Also I don't understand for what reason some program passes stdout to PHP. ------------------------------------------------------------------------ [2007-03-08 13:45:33] jostb2345 at yahoo dot com Description: ------------ On windows, php 5.2.0 and above the following code (written in pseudo-code) doesn't work anymore: socket = socket(AF_INET, ...); bind(socket, ...); listen(socket, ...); outputHandle=GetStdHandle(...); inputHandle=socket; CreateProcess(...,"php-cgi.exe", ..., IOHandles); The problem is that "is_fastcgi" is only set if the OutputHandle and ErrorHandle are invalid. If both are invalid, InputHandle is assumed to be a named pipe. The Unix version still uses the old (correct) code. To correct this problem either the old FCGI_isfcgi() should be used or the test must be dublicated. See procedures: int fcgi_init(void); int fcgi_is_fastcgi(void); Regards, Jost Boekemeier Reproduce code: --------------- See above. If necessary I can provide a test program. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=40758&edit=1