Stuff
public text v1 · immutable-module(pipe).
-compile(export_all).
%%---------------------------------------------------
%% 1> erl -s pipe -nouser < indata | tee outdata
%% 1 2 3 4 5
%% 5 4 3 2 1
%% 5 1 2 3 4
%% 4 3 2 1 5
%%---------------------------------------------------
start() ->
spawn(pipe,init,[]).
init() ->
Port = open_port({fd, 0, 1},[eof]),
loop(Port).
loop(Port) ->
receive
{Port, {data, What}} ->
Port ! {self(), {command, What}},
loop(Port);
{Port, eof} ->
halt()
end.