[erlang-questions] open_pipe({spawn, "cat"}) --- how to close stdin of cat?

Anthony Shipman als@REDACTED
Sun Mar 1 14:49:28 CET 2009


On Sun, 1 Mar 2009 09:48:36 pm C K Tan wrote:
> Michael,
>
> Without closing stdin of wc, wc never returns because it thought there
> are more data coming.
>
> wc(InputText) ->
>    P = open_port({spawn, "wc"}, [stream, exit_status, use_stdio,
>                            stderr_to_stdout, in, out, eof]),
>    port_command(P, InputText),
>    %% P ! {self(), {eof}},   %% ERROR -- how to close stdin of the wc
> process? receive {P, X} -> X end,
>    port_close(P).

What I have done is use an intermediate shell script. I write EOF or some 
similar marker to the port and the shell script closes the stdin for the 
command it controls.

-- 
Anthony Shipman                    Mamas don't let your babies 
als@REDACTED                   grow up to be outsourced.



More information about the erlang-questions mailing list