erlang:open_port compatability

Lukas Larsson lukas@REDACTED
Thu Dec 12 10:48:12 CET 2019


Hello,

While looking into a bug on Windows related to os:cmd/1 I found that the
behaviour of erlang:open_port when spawning port programs is somewhat
strange when it comes to the handling of stdin. In the current
implementation if you do this on Unix:

> erlang:open_port({spawn,"erl"},[in]).

You will get into a very strange state where the parent erl and the child
erl both compete for the input characters put into the terminal. If you do
it on Windows the child erl will just spin forever.

So, I'm thinking of making it so that when not supplying 'out' to
erlang:open_port the stdin fd will be closed in the child program or
alternatively point to /dev/null. This will more mimic Windows behaviour
(though there will be no spinning) and makes more sense in my opinion.

However, with the change, if you want to spawn an erlang child you need to
give it the -noinput argument as otherwise, it will exit immediately.

So the question for you all, will this change break any of your code?

Lukas
Erlang/OTP team
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20191212/d81e4573/attachment.htm>


More information about the erlang-questions mailing list