[erlang-questions] Issues with stdin on ports
Jesper Louis Andersen
jesper.louis.andersen@REDACTED
Mon Jul 29 14:08:07 CEST 2013
On Mon, Jul 29, 2013 at 6:14 AM, Anthony Grimes <i@REDACTED> wrote:
> 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.
I don't think ports were created with that use case in mind. Usually when
connecting Erlang to foreign programs, you have the advantage of being able
to specify the interface fully and then you can pick a better protocol than
"send message and then EOF". The deeper trouble here is that such an
interface means it is use-once. It will just blindly fork()/exec() programs
all the time and that hardly seems productive and efficient. It probably
will not scale very well and then you are looking at a framing solution on
the stream in any case.
Note the same problem is present with gen_tcp:shutdown/2. It seems
counterproductive to pay the handshake every time you want to communicate.
Another problem is that with a fork()/exec() solution you ctx switch to the
pygmentize process (or whatever process) for one processing only and then
you switch away again. You can't pipeline stuff to pygmentize and hence you
pay ctx switch overhead all the time.
In other words, I have a hard time seeing this to be useful, but you may
correct me on that if you have a better use case or can shoot down my
stream of thought.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130729/3d565fd4/attachment.htm>
More information about the erlang-questions
mailing list