httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Sutton <p...@ukweb.com>
Subject NT: spaces in paths
Date Wed, 22 Oct 1997 14:20:34 GMT
Um, the MSVC runtime is *correctly* handling quote-delimited arguments on
the command line (at least on NT). So

  apache -d "d:/program files/apache"

works fine, to start with. Then Apache spawns child processes. They have
argv's like this passed to spawn():

  argv[0] = apache
  argv[1] = -d
  argv[2] = d:/program files/apache
  argv[3] = NULL

So, no problem. But (and I can't believe this) when the child process
starts, it gets:

  argv[0] = apache
  argv[1] = -d
  argv[2] = d:/program
  argv[3] = files/apache

That is, WIN32 is *within the spawn()* function re-arranging the already
specified arguments based on whether the arguments contain spaces.  Does
it perhaps just printf all the argv[] options into a string. Umm, that's
what the info browser implies ("the combined lengths of the arguments,
plus the spaces inserted between the arguments, must not exceed 1024
bytes"). NOOOOO! This is madness. 

One work-around that seems to work is to quote all the arguments in
spawn()'s argv, like this:

  argv[0] = "apache"
  argv[1] = "-d"
  argv[2] = "d:/program files/apache"
  argv[3] = NULL

The patch (below) does this (this patch is not intended for use, just to
illustate the point). 

//pcs

--- /home/paul/remote-cvs/apachen/src/main/http_main.c	Tue Oct 21 08:17:40 1997
+++ ./http_main.c	Wed Oct 22 14:00:30 1997
@@ -4008,12 +4008,13 @@
     pass_argv[0] = argv[0];
     pass_argv[1] = "-c";
     pass_argv[2] = buf;
-    for (i = 1; i < argc; i++) {
-	pass_argv[i + 2] = argv[i];
+    for (i = 1; i < argc; i++) {
+        char *x = malloc(strlen(argv[i]+2));
+        sprintf(x, "\"%s\"", argv[i]);
+        pass_argv[i+2] = x;
     }
     pass_argv[argc + 2] = NULL;
 
-
     GetModuleFileName(NULL, mod, 200);
     rv = spawnv(_P_NOWAIT, mod, pass_argv);
 


Mime
View raw message