rse 98/05/28 04:09:47
Modified: src CHANGES src/modules/standard mod_rewrite.c mod_rewrite.h Log: Upgrade the child spawning code in mod_rewrite for the RewriteMap programs: ap_spawn_child_err() is used and the Win32 case now uses CreateProcess() instead of a low-level execl() (which caused problems in the past under Win32). Reviewed by: Ben Laurie Revision Changes Path 1.869 +6 -0 apache-1.3/src/CHANGES Index: CHANGES =================================================================== RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.868 retrieving revision 1.869 diff -u -r1.868 -r1.869 --- CHANGES 1998/05/28 10:57:56 1.868 +++ CHANGES 1998/05/28 11:09:44 1.869 @@ -1,4 +1,10 @@ Changes with Apache 1.3b8 + + *) Upgrade the child spawning code in mod_rewrite for the RewriteMap + programs: ap_spawn_child_err() is used and the Win32 case now uses + CreateProcess() instead of a low-level execl() (which caused problems in + the past under Win32). + [Ralf S. Engelschall] *) A few cosmetics and trivial enhancements to APXS to make the generated Makefile more user friendly. [Ralf S. Engelschall] 1.108 +40 -6 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c =================================================================== RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.107 retrieving revision 1.108 diff -u -r1.107 -r1.108 --- mod_rewrite.c 1998/05/27 14:01:38 1.107 +++ mod_rewrite.c 1998/05/28 11:09:45 1.108 @@ -3127,6 +3127,7 @@ rewrite_server_conf *conf; FILE *fpin; FILE *fpout; + FILE *fperr; array_header *rewritemaps; rewritemap_entry *entries; rewritemap_entry *map; @@ -3154,16 +3155,18 @@ continue; fpin = NULL; fpout = NULL; - rc = spawn_child(p, rewritemap_program_child, (void *)map->datafile, - kill_after_timeout, &fpin, &fpout); + rc = ap_spawn_child_err(p, rewritemap_program_child, + (void *)map->datafile, kill_after_timeout, + &fpin, &fpout, &fperr); if (rc == 0 || fpin == NULL || fpout == NULL) { - perror("spawn_child"); + perror("ap_spawn_child"); fprintf(stderr, "mod_rewrite: " "could not fork child for RewriteMap process\n"); exit(1); } map->fpin = fileno(fpin); map->fpout = fileno(fpout); + map->fperr = fileno(fperr); } return; } @@ -3173,17 +3176,48 @@ { int child_pid = 1; + /* + * Prepare for exec + */ ap_cleanup_for_exec(); #ifdef SIGHUP signal(SIGHUP, SIG_IGN); #endif + + /* + * Exec() the child program + */ #if defined(WIN32) - child_pid = spawnl(_P_NOWAIT, SHELL_PATH, SHELL_PATH, - "/c", (char *)cmd, NULL); + /* MS Windows */ + { + char *pCommand; + STARTUPINFO si; + PROCESS_INFORMATION pi; + + pCommand = strcat(SHELL_PATH, " /C ", cmd, NULL); + + memset(&si, 0, sizeof(si)); + memset(&pi, 0, sizeof(pi)); + + si.cb = sizeof(si); + si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; + si.wShowWindow = SW_HIDE; + si.hStdInput = pinfo->hPipeInputRead; + si.hStdOutput = pinfo->hPipeOutputWrite; + si.hStdError = pinfo->hPipeErrorWrite; + + if (CreateProcess(NULL, pCommand, NULL, NULL, TRUE, 0, + environ, NULL, &si, &pi)) { + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); + child_pid = pi.dwProcessId; + } + } #elif defined(__EMX__) - /* OS/2 needs a '/' */ + /* IBM OS/2 */ execl(SHELL_PATH, SHELL_PATH, "/c", (char *)cmd, NULL); #else + /* Standard Unix */ execl(SHELL_PATH, SHELL_PATH, "-c", (char *)cmd, NULL); #endif return(child_pid); 1.52 +1 -0 apache-1.3/src/modules/standard/mod_rewrite.h Index: mod_rewrite.h =================================================================== RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.h,v retrieving revision 1.51 retrieving revision 1.52 diff -u -r1.51 -r1.52 --- mod_rewrite.h 1998/05/20 15:34:27 1.51 +++ mod_rewrite.h 1998/05/28 11:09:46 1.52 @@ -252,6 +252,7 @@ int type; /* the type of the map */ int fpin; /* in file pointer for program maps */ int fpout; /* out file pointer for program maps */ + int fperr; /* err file pointer for program maps */ char *(*func)(request_rec *, /* function pointer for internal maps */ char *); } rewritemap_entry;