Terminal now writes to fd 1, not fd 0.

Fixes problem where `./program </dev/null` didn't show output.
This commit is contained in:
George Koehler 2017-10-28 17:20:39 -04:00
parent 75ae957c75
commit 9a965efae8

View file

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