[erlang-questions] erl_ddll:load_driver behaviour.
Amit Kapoor
amit@REDACTED
Tue Dec 11 00:46:40 CET 2012
Hi folks,
Trying to understand load_drive behaviour. The test code I am using is at the
end of this email. The driver being loaded is a dummy driver with a printf
message in the DRIVER_INIT code. If I call spawn:test(true,3), the printf
message in DRIVER_INIT code gets displayed 3 times, whereas spawn:test(false,3)
displays the same message only once. The erl_ddll manual is a bit lacking in
this area, so wanted to get some clarification.
1. Is this the expected behaviour?
2. Child processes seem to 'inherit' drivers loaded by parent process?
regards
Amit
===================================================
-module(spawn).
-export([test/2, load_driver/0]).
test(_, 0) ->
ok;
test(Spawn, Count) ->
case Spawn of
true -> spawn(fun() -> load_driver() end);
false -> load_driver()
end,
timer:sleep(5000),
test(Spawn, Count - 1).
load_driver() ->
case erl_ddll:load_driver("/home/user", test_drv) of
ok -> ok;
{error, already_loaded} -> ok
end.
More information about the erlang-questions
mailing list