Terminal now writes to fd 1, not fd 0.
authorGeorge Koehler <xkernigh@netscape.net>
Sat, 28 Oct 2017 21:20:39 +0000 (17:20 -0400)
committerGeorge Koehler <xkernigh@netscape.net>
Sat, 28 Oct 2017 21:20:39 +0000 (17:20 -0400)
Fixes problem where `./program </dev/null` didn't show output.

lang/m2/libm2/Terminal.mod

index 120aba7..c26a856 100644 (file)
@@ -19,7 +19,7 @@ IMPLEMENTATION MODULE Terminal;
 #else
   FROM Unix IMPORT     read, write, open, ioctl;
 #endif
-  VAR fildes: INTEGER;
+  VAR fildes, fdout: INTEGER;
       unreadch: CHAR;
       unread: BOOLEAN;
       tty: ARRAY[0..8] OF CHAR;
@@ -87,7 +87,7 @@ IMPLEMENTATION MODULE Terminal;
 
   PROCEDURE Write(ch: CHAR);
   BEGIN
-       IF write(fildes, ADR(ch), 1) < 0 THEN
+       IF write(fdout, ADR(ch), 1) < 0 THEN
                ;
        END;
   END Write;
@@ -116,5 +116,6 @@ BEGIN
 (* dtrg: changed so that instead of opening /dev/tty, fd 0 is always used. *)
     tty := "stdio";
     fildes := 0;
+    fdout := 1;
     unread := FALSE;
 END Terminal.