Using an external unix filter

Carsten Schultz <>
Fri Apr 9 16:34:18 CEST 2004


Hi,

how can I close the stdin of a spawned port and still collect its
output?  I would like to do something like


Port = open_port({spawn, SOME_UNIX_FILTER}, [exit_status, binary]),
Port ! {self(), {command, Data}},
SOMEHOW TELL THE PORT I WILL NOT SEND MORE DATA,
collect_loop(Port, []).

collect_loop(Port, Acc) ->
    receive
	M={Port, {data, Bin}} ->
	    collect_loop(Port, [Acc, Bin]);
	M={Port, _} ->
	    Acc
    end.


Thanks in advance,

Carsten

-- 
Carsten Schultz (2:38, 33:47), FB Mathematik, FU Berlin
http://carsten.codimi.de/
PGP/GPG key on the pgp.net key servers, 
fingerprint on my home page.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20040409/4b4a611f/attachment.bin>


More information about the erlang-questions mailing list