[M3devel] new problem on NT386

Randy Coleburn rcoleburn at scires.com
Wed Jan 23 20:55:21 CET 2008


Olaf:
 
THANKS!  It is obvious that these changes to QMachine are responsible
for the problems.  It would have taken me forever to find this.  Thanks
so much!
 
I changed the quake procedures to use "&&" instead of "|" and the
build/ship routines seem to work again.  Indeed, I even went back and
put the comment back in Jay's cm3.cfg and it still works without
crashing in M3Path.  This is very good!
 
Now, I am not real good at parsing thru these text diff files, but am I
seeing there was also a change to QMachine that involves how the output
is being redirected?
 
What I am observing in reactor, is that the build/ship/clean/etc output
is not being shown in the browser window.  Since these functions are
being called via a quake procedure, if the QMachine has been altered
somehow not to allow this output to be redirected, then reactor is going
to have a real problem.  The output of these quake routines is showing
up in the console log window instead of being redirected back to the
browser as it was in 4.1 and 5.2.6.
 
Regards,
Randy

>>> Olaf Wagner <wagner at elegosoft.com> 1/23/2008 1:32 PM >>>
Quoting Randy Coleburn <rcoleburn at scires.com>:

> Olaf:
>
> The pipe symbol is used by reactor in the quake exec() calls.  I did
> not program this; it was done by CMass Inc.  My experience has been
that
> the pipe worked as a command separator in the quake exec() call, even
on
> the Unix systems.  I agree it looks strange, but then, I'm not a
quake
> expert.

Is this documented anywhere? The online doc says

exec(...) The arguments are catenated and passed to the operating  
system to be executed as a child process. The command may start `-' or 

`@'. These are stripped before the command is passed to the command  
interpreter. A prefix of `@' indicates that the default action of  
printing the command to the standard output stream before execution  
should be overridden. A prefix character of `-' overrides quake's  
default action of aborting if it detects an error return code after  
executing the command.

I've never seen it, and it seems a really strange choice to me, since
it would make it impossible to use pipes within a command.

OK, I've found it, but didn't know it ever existed ;-)
Here is the diff:

% cvs diff -u -r 1.3 -r 1.4 m3-sys/m3quake/src/QMachine.m3
Index: m3-sys/m3quake/src/QMachine.m3
===================================================================
RCS file: /usr/cvs/cm3/m3-sys/m3quake/src/QMachine.m3,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -u -r1.3 -r1.4
--- m3-sys/m3quake/src/QMachine.m3      25 Jun 2003 14:36:32 -0000     
1.3
+++ m3-sys/m3quake/src/QMachine.m3      16 Oct 2005 13:43:32 -0000     
1.4
@@ -1354,7 +1354,6 @@
      quake_in     : Pipe.T;
      process_out  : Pipe.T;
      wr           : Wr.T := CurWr (t);
-    wd           : TEXT;
      inbuf        : ARRAY [0..255] OF CHAR;
    BEGIN
      info.command := "";
@@ -1396,8 +1395,6 @@
        Err (t, "write failed" & OSErr (ec));
      END;

-    wd := ExtractInitialDir (info.command);
-
      args [0] := t.sh_option;
      args [1] := info.command;
      n_shell_args := 2;
@@ -1410,7 +1407,7 @@
          (* fire up the subprocess *)
          handle := Process.Create (t.shell, SUBARRAY (args, 0,
n_shell_args),
                                   stdin := stdin, stdout :=
process_out,
-                                 stderr := process_out, wd := wd);
+                                 stderr := process_out);
          (* close our copy of the writing end of the output pipe *)
          process_out.close ();
          LOOP (* send anything coming through the pipe to the quake  
output file *)
@@ -1439,38 +1436,6 @@
      RETURN info;
    END ExecCommand;

-PROCEDURE ExtractInitialDir (VAR cmd: TEXT): TEXT =
-  (* search for "cd <dir> |" or "cd <dir> ;" prefix in "cmd".
-     If it's found, return "<dir>" and remove the prefix from "cmd".
-     Otherwise, return "NIL". *)
-  VAR
-    len := Text.Length (cmd);
-    buf : ARRAY [0..99] OF CHAR;
-    start, stop: INTEGER;
-    dir: TEXT;
-  BEGIN
-    IF (len < 5) THEN RETURN NIL; END;
-    Text.SetChars (buf, cmd);
-    start := 0;
-    WHILE (start < len) AND (buf[start] = ' ') DO INC (start); END;
-    IF (start+4 >= len)     THEN RETURN NIL; END;
-    IF (buf[start]   # 'c') THEN RETURN NIL; END;
-    IF (buf[start+1] # 'd') THEN RETURN NIL; END;
-    IF (buf[start+2] # ' ') THEN RETURN NIL; END;
-    INC (start, 3);
-    WHILE (start < len) AND (buf[start] = ' ') DO INC (start); END;
-    stop := start;
-    WHILE (stop < len) AND (buf[stop] # ' ')
-      AND (buf[stop] # '|') AND (buf[stop] # ';') DO INC (stop); END;
-    IF (stop <= start) THEN RETURN NIL; END;
-    dir := Text.FromChars (SUBARRAY (buf, start, stop - start));
-    WHILE (stop < len) AND (buf[stop] = ' ') DO INC (stop); END;
-    IF (stop >= len) THEN RETURN NIL; END;
-    IF (buf[stop] # '|') AND (buf[stop] # ';') THEN RETURN NIL; END;
-    cmd := Text.Sub (cmd, stop+1);
-    RETURN dir;
-  END ExtractInitialDir;
-
  PROCEDURE KillProcess (handle: Process.T) =
    BEGIN
      IF (handle # NIL) THEN

Obviously it has been remove by rillig (Robert Illig?):

revision 1.4
date: 2005-10-16 13:43:32 +0000;  author: rillig;  state: Exp;  lines:
+1 -36;
Removed the superfluous and error prone ExtractInitialDir procedure,
which had tried to parse the shell command, and if it starts with "cd
",
changed to that directory itself.

So it only looked for cd dir | and then changed the directory
accordingly, but it really was an undocumented hack and is not needed.
I'd suggest to just use 'cd dir &&' instead. If that doesn't work,
please let me know.

A grep through the sources for 'cd .*\|' should reveal all occurences.
If you need more enhanced execution functions, I can also contribute
a module with much better abstractions for running commands.

Olaf
-- 
Olaf Wagner -- elego Software Solutions GmbH
                Gustav-Meyer-Allee 25 / Gebäude 12, 13355 Berlin,
Germany
phone: +49 30 23 45 86 96  mobile: +49 177 2345 869  fax: +49 30 23 45
86 95
    http://www.elegosoft.com ( http://www.elegosoft.com/ ) |
Geschäftsführer: Olaf Wagner | Sitz: Berlin
Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr:
DE163214194


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20080123/e3f2ef35/attachment-0002.html>


More information about the M3devel mailing list