[erlang-questions] Erlang VM crashed due to io output?
Daniel Luna
luna@REDACTED
Thu Jul 19 13:32:58 CEST 2007
On Thu, 19 Jul 2007, Ludovic Coquelle wrote:
> Sorry for posting again this question, but I think there is something
> important to know and I can't figure out what.
>
> I run a command printing simple text on default io device (stdout):
> bash> erl -noshell -eval "lists:foreach(fun(N) -> io:format(\"~w~n\", [N])
> end, lists:seq(1,5)), erlang:halt()."
> 1
> 2
> 3
> 4
> 5
>
> That's the behaviour I expected.
> But if I try to pipe the result, erlang crash:
> bash> erl -noshell -eval "lists:foreach(fun(N) -> io:format(\"~w~n\", [N])
> end, lists:seq(1,5)), erlang:halt()." | head -n 3
> 1
> 2
> 3
> Crash dump was written to: erl_crash.dump
> init terminating in do_boot ()
>
> What's happening?
> Is it a normal behaviour?
I was hoping someone else would answer, and thus didn't reply to your
first message.
I'm not suprised at all, but my answer should still be taken with a grain
of salt.
My guess is that 'head -n 3' will take the first three lines of output and
then kill the pipe. Erlang will be very upset about someone killing its
standard out, and thus crash (and of course the error message is written
to stderr and thus not caught by head).
If it's ok that erlang crashes, you could pipe also stderr, otherwise I
recommend that you do the head thingie inside erlang.
HTH
/Luna
--
Daniel Luna | Top reasons that I have a beard:
luna@REDACTED | a) Laziness.
http://www.update.uu.se/~luna/ | b) I can.
Don't look at my homepage (it stinks).| c) I can get away with it.
More information about the erlang-questions
mailing list