epipe error on port, uncatchable exception
Péter Szilágyi
peterke@REDACTED
Sun May 9 21:27:56 CEST 2010
Hi,
I've been trying to get some basic port operations going, but sometimes I
get a very peculiar error: epipe exception. The problem is that according to
the documentation this should never happen, yet it does, what's more ,
completely randomly. I can execute the same command and one time is
succeeds, another time it fails (let's say 1/10 failures). The even more
interesting part is, that I cannot catch the exception.
I've written a very basic module to reproduce the error, which just
executes "ls -al" 1000 times (see below), passing in a small input data
(this is the reason of the crash).
The exception below doesn't happen on all machines (I'm using openSuSE
11.2 x64, with Erlang R13B04 (also x64)). On an Ubuntu it ran just fine. Now
it may turn out that the OS is doing something strange causing the broken
pipes, BUT even so, I should be able to catch it.
Any feedback is appreciated,
Peter
portbug.erl:
----------
-module(portbug).
-compile(export_all).
crash_it() ->
try lists:foreach(fun(_) -> do_something_portlike() end,
lists:seq(1, 1000))
catch
Class:Exception -> io:format("Caught: ~p:~p", [Class,
Exception])
end.
do_something_portlike() ->
Command = "ls -al",
Port = open_port({spawn, Command}, [stream, use_stdio,
stderr_to_stdout, binary, eof]),
Port ! {self(), {command, <<"some random data">>}},
Port ! {self(), close}.
----------
(shell@REDACTED)232> portbug:crash_it().
exception exit: epipe**
----------
More information about the erlang-bugs
mailing list