Question about ports & eof

Chris Pressey <>
Sat Jul 20 09:39:06 CEST 2002

Is there any way to send an eof to a port without closing it?

I want to call a program and give it some data on standard input.  The
problem is that it won't give me back any data on standard output until it
gets an eof.

Basically something like...


  start() ->
    P = open_port({spawn, "tar -c -f - -I -"}, [stream, use_stdio, eof]),
    port_command(P, "foo\nbar\nbaz\n"),
    port_command(P, eof), % if only it were this simple
  loop(P) ->
      {P, {data, Data}} ->
        io:fwrite("~p~n", [Data]),
      {P, eof} ->

I guess I might have to resort to a tmpfile here...


More information about the erlang-questions mailing list