EOF to external program
Timo Lindemann
timo.lindemann@REDACTED
Fri Nov 5 21:36:17 CET 2010
Hello erlangers,
I like to use external programs, so I thought I could use ports a lot. I
fail to understand one detail about ports: Why can one not close the write
end (such that the connected external program registers an EOF on its stdin
descriptor)?
I dug around the web some, and found that this has stumped other people in
the past, with suggestions about using netcat to work around that problem,
to writing a wrapper that parses the data for some marker the process would
send to the external program signalling EOF and have the wrapper close the
write end.
Why is there NO way in erlang to let a program know the input's data has
ended *and* fetching its response *and* getting its (normal) exit status?
port_close/1 will normally instantly kill the external program.
Omitting this feature severely limits the things one can do with ports. awk
will not process its END clause, wc will never exit, ... if there's no EOF
to be found. There's a lot of programs waiting for stdin to close.
So please, what's the reason for not allowing this? Will this be added
sometime later on? Or have I just not found a way to do it?
All the best
-T.
--
Timo Lindemann
Software Systems Engineer
More information about the erlang-questions
mailing list