httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Sutton <p...@ukweb.com>
Subject [BUG] NT fixup for failed spawn of child
Date Mon, 20 Oct 1997 15:35:39 GMT
I think the recent patch to catch a failure to spawn a child process looks
wrong, and I cannot make Apache work with it in. Specifically, at the
moment alloc.c (spawn_child_err_core) returns a "pid" of -1 to indicate an
error, but spawn_child_err() and mod_cgi.c assume that any non-zero PID
means the spawn worked. Also the alloc.c code logs the error without
mentioning the program name that failed, because it doesn't know it.
mod_cgi.c already has the code to correctly log the failure of the spawn,
as used by Unix.  We should reuse this code. 

This patch is very simple. Until Win32 if the spawn*() fails it returns
-1. This patch catches this case and sets the pid value to 0. The rest of
the Apache code treats a PID of 0 as meaning that the spawn failed, so
everything works fine. It also removes the logging from alloc.c. 

//pcs

Index: alloc.c
===================================================================
RCS file: /export/home/cvs/apachen/src/main/alloc.c,v
retrieving revision 1.52
diff -u -r1.52 alloc.c
--- alloc.c	1997/10/20 12:08:58	1.52
+++ alloc.c	1997/10/20 15:30:35
@@ -1300,9 +1300,10 @@
 	    close(err_fds[1]);
 	}
 
-	pid = (*func) (data);
-	if (pid == -1) {
-	    /* If we are going to save it, we ought to do something with it later, right? - Ben
*/
+	pid = (*func) (data);
+        if (pid == -1) pid = 0;     // map Win32 error code onto Unix default
+
+        if (!pid) {
 	    save_errno = errno;
 	    close(in_fds[1]);
 	    close(out_fds[0]);
@@ -1317,9 +1318,7 @@
 	if (pipe_err)
 	    dup2(hStdErr, fileno(stderr));
 
-	if(pid == -1)
-	    aplog_error(APLOG_MARK, APLOG_ERR, NULL, "spawn failed");
-	else {
+        if (pid) {
 	    note_subprocess(p, pid, kill_how);
 	    if (pipe_in) {
 		*pipe_in = in_fds[1];



Mime
View raw message