[erlang-questions] Issues with stdin on ports

Serge Aleynikov serge@REDACTED
Wed Jul 31 17:38:34 CEST 2013


Speaking of erlexec - I just added experimental support to erlexec to
read STDOUT and STDERR from spawned processes and redirect them to
either a custom function or an Erlang Pid:

See: http://saleyn.github.io/erlexec/

10> exec:run("echo Hello World!; echo ERR!! 1>&2", [{stdout, self()},
{stderr, self()}]).
{ok,<0.247.0>,18585}
11> flush().
Shell got {stdout,18585,<<"Hello World!\n">>}
Shell got {stderr,18585,<<"ERR!!\n">>}
ok

On 7/31/2013 4:10 AM, David Welton wrote:
>> 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.
> 
> You might look into erlexec: https://github.com/saleyn/erlexec
> 
> It currently does not handle the communication part of things that you
> need, but on the other hand, it's very hackable, the author is
> friendly, and responds quickly to new ideas, so it probably would not
> be that hard to add what you need to it.  And it is an external
> program itself, so even if it's compiled code, you don't run the risk
> of crashing your Erlang process by using it.
> 
> Erlang's handling of external programs leaves something to be desired
> compared to other languages:
> 
> * You can't kill them.
> 
> * You can't treat stdin and stderr as separate streams.
> 
> Are two important ones that come to mind.
> 



More information about the erlang-questions mailing list