Skip to content

Commit

Permalink
Terminal now writes to fd 1, not fd 0.
Browse files Browse the repository at this point in the history
Fixes problem where `./program </dev/null` didn't show output.
  • Loading branch information
kernigh committed Oct 28, 2017
1 parent 75ae957 commit 9a965ef
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lang/m2/libm2/Terminal.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.

0 comments on commit 9a965ef

Please sign in to comment.