[erlang-questions] Issues with stdin on ports

Anthony Grimes i@REDACTED
Mon Jul 29 06:14:04 CEST 2013


Howdy folks.

I unfortunately have not been able to use Erlang for most of what I've
been doing lately because of a long standing issue with Erlang ports
that I'd like to start a discussion about here.

As far as I am aware, ports are generally the only option for creating
and communicating with external processes in Erlang. They seem to have
at least one particular fatal flaw which prevents them from being very
useful to me, and that is that there is no way to close stdin (and send
EOF) and then also read from the process's stdout. For example, I cannot
use a port to start the 'cat' program which listens on stdin for data
and waits for EOF and then echos that data back to you. I can do the
first part, which is send it data on stdin, but the only way for me to
close it is to call port_close and close the entire process.

This issue prevents Erlang users from doing any even slightly more than
trivial communication with external processes without having some kind
of middleman program that handles the creation of the actual process you
need to talk to and looks for a specific byte sequence to indicate 'EOF'.

I could totally be wrong, but it seems like we need something other than
just port_close. Something like
http://www.erlang.org/doc/man/gen_tcp.html#shutdown-2 
<http://www.erlang.org/doc/man/gen_tcp.html#shutdown-2>which lets you say
"Hey, I want to close the stdin of this process but still read from its
stdout." or something similar. I could be totally off track on what a
good solution would be.

So I'm wondering if people are aware of this problem, and I'd like to
make sure that people think it is an actual problem that should be
fixed. I'm also curious what people think a good solution to the problem
would be. I'm not sure I have the time/particular skill set to fix it
given that the port code is some pretty obscure (to me) C code, but
starting conversation seems like a good way to begin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130728/68361264/attachment.htm>


More information about the erlang-questions mailing list