Windows, io:fwrite, halt, buffer flushing problems, R10B-2
Thu Jan 27 21:43:33 CET 2005
I encountered a little problem on Windows: I have code like the following:
test() -> io:fwrite("test~n"), halt(1).
which behaves strangely: sometimes nothing is printed on screen. I
assume it is some problem with flushing a buffer. Using init:stop/0
instead of halt/1 solves the problem, but I wanted to return explicitly
another error code than 0.
In the code I encountered this problem first, the problem occured more
often. I searched for a function flushing the standard output, but
didn't found such in the kernel and stdlib manuals to solve this
problem. After putting "receive after N -> ok end" between the fwrite
and halt the problem seemed to vanish (depending on N ...).
The interesting thing is, that there is no such problem on Mac OS X and
NetBSD. I first thought, that this may be caused by the slower
cpus/hardware. The win32-box has no other system installed, so I tried
coLinux to test if it is caused by the faster cpu, but in coLinux it
worked (but I don't know if and how big the speed loss is ...).
I browsed the mailing list archive, but didn't found something about
this. Hope that I am not blind :)
I never looked at the implementation of Erlang to track down the
problem, but for me it seems to be a Windows specific problem.
Ok here the technical details:
Windows XP SP 2, Erlang/OTP R10B-2 installed from the binary installer
found at www.erlang.org
(the working setups - Mac OS X, ... - are self-compiled R10B-2 from source)
More information about the erlang-questions