[erlang-questions] Using select in a Port

Per Hedeland per@REDACTED
Wed Oct 24 22:22:28 CEST 2007


jm <jeffm@REDACTED> wrote:
>
>jm wrote:
>> Per Hedeland wrote:
>>> jm <jeffm@REDACTED> wrote:
>>>> it appears somthing is causing erlang to close stdin to the port,
>>> Yes, that was pretty clear from your earlier results.
>> 
>> Just had to prove it.
>
>In continuing to debug this port program I recompile with debug enabled 
>(-g) and attached gdb to the running process which resulted in it 
>writting to a broken pipe as shown

Yes, that is also the expected result if it tries to write to the pipe
after Erlang has closed its end. I don't think you actually answered my
question earlier:

>>> Is the port owner process still running? The port gets automatically
>>> closed when the owner exits.

I.e. I'm referring to the Erlang process that opened the port (unless
you have changed the port owner with e.g. port_connect/2). That process
exiting is the most likely cause of the port getting closed from the
Erlang side. Possibly the port could also be closed by the runtime if
you have specifed some more "advanced" "protocol" than
stream/packet/line and the incoming data doesn't follow it (any random
data can be interpreted as being either of those three), but in that
case the port owner should get an exit signal.

--Per



More information about the erlang-questions mailing list