erlang:open_port compatability

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

erlang:open_port compatability

Lukas Larsson-8
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