[erlang-questions] Erlang-C port not working on some unix machines
Thu Apr 5 17:03:15 CEST 2012
On Thu, Apr 5, 2012 at 4:47 AM, Richard Evans
> If you guys have any pointers or suggestions or anything, I would be
> very grateful.
Since you've proven you're writing all of the data on the C side, I
would guess that somehow the data is getting buffered between C and
Erlang. You've said you're using the standard example, so you're not
using stdout (which is buffered by libc and would need an fflush()).
I believe Erlang uses a pipe() to communicate with a standard port
drive and pipes aren't buffered, so fsync() wouldn't help ... although
I suppose you should look at the docs on your "unix pdp" to see that
there are no non-POSIX gotchas.
I'm not 100% sure what you mean by "unix pdp" (I think they stopped
making PDP's in the 80's) However, look for a tool called strace, if
you start up your Erlang process you can use ps to find the pid of
both the beam process and your port driver. Attach an strace to each
and you'll be able to see the I/O going back and forth between Erlang
and the C program. Most importantly, you should see Erlang do the
"read" of your response.
If your "unix pdp" doesn't have strace, there are a few alternatives,
truss (Solaris?) and dtrace (newer UNIXes) that will do the same
Hope this helps.
More information about the erlang-questions