httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@hyperreal.org
Subject cvs commit: apachen/src/main alloc.c util_script.c
Date Mon, 20 Oct 1997 12:09:00 GMT
ben         97/10/20 05:09:00

  Modified:    src/main alloc.c util_script.c
  Log:
  Fix CGI under Win95 (plus some error checking). This needs doing more carefully.
  
  Revision  Changes    Path
  1.52      +18 -10    apachen/src/main/alloc.c
  
  Index: alloc.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/main/alloc.c,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- alloc.c	1997/10/15 00:25:14	1.51
  +++ alloc.c	1997/10/20 12:08:58	1.52
  @@ -60,6 +60,7 @@
   
   #include "httpd.h"
   #include "multithread.h"
  +#include "http_log.h"
   
   #include <stdarg.h>
   
  @@ -1217,9 +1218,9 @@
   }
   
   #ifdef WIN32
  -#define enc_pipe(fds) _pipe(fds, 512, O_TEXT | O_NOINHERIT)
  +#define os_pipe(fds) _pipe(fds, 512, O_BINARY | O_NOINHERIT)
   #else
  -#define enc_pipe(fds) pipe(fds)
  +#define os_pipe(fds) pipe(fds)
   #endif /* WIN32 */
   
   /* for fdopen, to get binary mode */
  @@ -1239,11 +1240,11 @@
       int err_fds[2];
       int save_errno;
   
  -    if (pipe_in && enc_pipe(in_fds) < 0) {
  +    if (pipe_in && os_pipe(in_fds) < 0) {
   	return 0;
       }
   
  -    if (pipe_out && enc_pipe(out_fds) < 0) {
  +    if (pipe_out && os_pipe(out_fds) < 0) {
   	save_errno = errno;
   	if (pipe_in) {
   	    close(in_fds[0]);
  @@ -1253,7 +1254,7 @@
   	return 0;
       }
   
  -    if (pipe_err && enc_pipe(err_fds) < 0) {
  +    if (pipe_err && os_pipe(err_fds) < 0) {
   	save_errno = errno;
   	if (pipe_in) {
   	    close(in_fds[0]);
  @@ -1281,22 +1282,27 @@
   	/* Now do the right thing with your pipes */
   	if (pipe_in) {
   	    hStdIn = dup(fileno(stdin));
  -	    dup2(in_fds[0], fileno(stdin));
  +	    if(dup2(in_fds[0], fileno(stdin)))
  +		aplog_error(APLOG_MARK, APLOG_ERR, NULL, "dup2(stdin) failed");
   	    close(in_fds[0]);
   	}
   	if (pipe_out) {
   	    hStdOut = dup(fileno(stdout));
  -	    dup2(out_fds[1], fileno(stdout));
  +	    close(fileno(stdout));
  +	    if(dup2(out_fds[1], fileno(stdout)))
  +		aplog_error(APLOG_MARK, APLOG_ERR, NULL, "dup2(stdout) failed");
   	    close(out_fds[1]);
   	}
   	if (pipe_err) {
   	    hStdErr = dup(fileno(stderr));
  -	    dup2(err_fds[1], fileno(stderr));
  +	    if(dup2(err_fds[1], fileno(stderr)))
  +		aplog_error(APLOG_MARK, APLOG_ERR, NULL, "dup2(stdin) failed");
   	    close(err_fds[1]);
   	}
   
   	pid = (*func) (data);
  -	if (!pid) {
  +	if (pid == -1) {
  +	    /* If we are going to save it, we ought to do something with it later, right? - Ben
*/
   	    save_errno = errno;
   	    close(in_fds[1]);
   	    close(out_fds[0]);
  @@ -1311,7 +1317,9 @@
   	if (pipe_err)
   	    dup2(hStdErr, fileno(stderr));
   
  -	if (pid) {
  +	if(pid == -1)
  +	    aplog_error(APLOG_MARK, APLOG_ERR, NULL, "spawn failed");
  +	else {
   	    note_subprocess(p, pid, kill_how);
   	    if (pipe_in) {
   		*pipe_in = in_fds[1];
  
  
  
  1.79      +6 -0      apachen/src/main/util_script.c
  
  Index: util_script.c
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/main/util_script.c,v
  retrieving revision 1.78
  retrieving revision 1.79
  diff -u -r1.78 -r1.79
  --- util_script.c	1997/10/15 23:37:47	1.78
  +++ util_script.c	1997/10/20 12:08:59	1.79
  @@ -668,6 +668,7 @@
   	int i, sz;
   	char *dot;
   	char *exename;
  +	char *s;
   	int is_exe = 0;
   
   	interpreter[0] = 0;
  @@ -732,6 +733,11 @@
   
   	    }
   	}
  +	/* FIXME: Probably ought to do this in another buffer - Ben */
  +	/* This really annoys me - Win95 (and not NT) spawn[vl]e don't like '/'! - Ben */
  +	for(s=r->filename ; *s ; ++s)
  +	    if(*s == '/')
  +		*s='\\';
   
   	if ((!r->args) || (!r->args[0]) || (ind(r->args, '=') >= 0)) {
   	    if (is_exe || is_binary) {
  
  
  

Mime
View raw message