[erlang-questions] Process unexpectedly locks up

Sam Bobroff sam@REDACTED
Tue May 4 07:41:43 CEST 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Doug (and the list),

(I'll reply to the questions list)

[...]

> I've received this reply from Sam Bobroff, which indicates
> there is some kind of conflict with "io:wait_io_mon_reply".

I'll add to my previous reply:

I think you have two options:

1. Use the interactive shell (don't use "-noshell" on the command line):

Since you can't use io:get_line(), you could modify the "down" handler
in me_loop() in two places:

* if the down case requires a decision, just print out the options (as
now) and otherwise don't do anything.

* add a handler for a {down, X} message that takes choice X as if it had
been returned from get_user_input() in the old code.

So now you do "me ! down" and get a message that it failed, with your
options, then you do "me ! {down, 1}" to pick one. You never use
get_line() so there is no conflict.

2. Don't use the shell (so *do* use "-noinput"):

Since you're not using the shell, you can't drive the threads using
messages. Instead, have the start() function continue on into an
interactive loop calling get_line() and translating it into up, down or
whatever, messages sent to "me". Then when you want to make a choice you
can just call get_user_input() as you do now.

I don't really think there's a bug (in Erlang) but the documentation for
get_line would certainly be better if it said something about the
interaction between the shell and the io input functions.

Cheers,
Sam.

- -- 
Sam Bobroff | sam@REDACTED | M5 Networks
Why does my email have those funny headers? Because I use PGP to sign
my email (and you should too!): that's how you know it's really from me.
See: http://en.wikipedia.org/wiki/Pretty_Good_Privacy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkvfs5YACgkQm97/UHSa/AQg3QCfT/Gmk+TQujmgv2NE+lMCAICB
GvAAn3ICuTCwetbNz4zFQEBpUDAKp0La
=rJh5
-----END PGP SIGNATURE-----


More information about the erlang-questions mailing list