[erlang-questions] erlang port and C executable

Edwin Fine erlang-questions_efine@REDACTED
Sun Nov 23 20:21:48 CET 2008


On Sun, Nov 23, 2008 at 2:08 PM, Per Hedeland <per@REDACTED> wrote:

> Johnny Billquist <bqt@REDACTED> wrote:
> >
> >Per Hedeland wrote:
> >> "Edwin Fine" <erlang-questions_efine@REDACTED> wrote:
> >>> One of the most annoying aspects is that under
> >>> circumstances that are not clear to me, the C program that is spawned
> >>> sometimes does not seem to be sent a signal for end of file when you
> close
> >>> the port, so if it is reading stdin, it's just going to sit there until
> >>> killed manually.
> >>
> >> This should never happen - i.e. there is no "signal" for end of file,
> >> it's just the result of reading when there is nothing more to read - but
> >> a port program that actually reads its stdin should always get end of
> >> file when the port is closed (after having read what there is to read,
> >> if anything). "You're probably doing something wrong."
> >
>

I misspoke (miswrote :) about the signal. <Hits head> Of course closing a
write pipe will make the reading program receive an EOF - everything's a
file in Unix (except the things that aren't ;). Sorry. I should learn not to
post at 2am.

How about this for a suggestion: add an optional parameter to port_close:

erlang:port_close(Port, Opts)
Opts = [brutal_kill | polite_shutdown]

Omitting the opts will give the same behavior as current; adding a
[brutal_kill] will do the equivalent of a kill -9; polite shutdown just a
"normal" kill.

Regards,
Edwin Fine
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081123/789aa954/attachment.htm>


More information about the erlang-questions mailing list