eof not handled in Windows files?

isaac gouy igouy@REDACTED
Fri Aug 2 22:08:09 CEST 2002


It seems that several people have had problems
redirecting files to stdio using the Windows Console. 

In this program, eof never seems to match in the
receive loop but [] will match? I've tried creating
the file with notepad (which doesn't use an eof char)
and edlin which does insert an eof char. The eof char
inserted by edlin doesn't match with eof.

%% erl -noinput -s pipe start < data.txt

-module(pipe).
-compile(export_all).

start() ->
    spawn(pipe,init,[]).

init() ->
    Port = open_port({fd, 0, 1},[eof]),
    loop(Port).

loop(Port) ->
    receive
	{Port, eof} -> %% never matches !
            io:format("~n~s ~n", ["Matched eof"]),
            halt();
	{Port, {data, []}} -> 
            io:format("~n~s ~n", ["Matched []"]),
            halt();
	{Port, {data, What}} ->
	    Port ! {self(), {command, What}},
	    loop(Port)
    end.

Any suggestions on how to get eof to work?

cheers Isaac


__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com



More information about the erlang-questions mailing list