diff options
author | Erlang/OTP <[email protected]> | 2010-10-21 12:09:25 +0200 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2010-10-21 12:09:25 +0200 |
commit | 7343ad05132654c2b5b8366d05991128a28a9a01 (patch) | |
tree | c6196de1d2459a326a3b0b122aa1721c630b21d0 /lib | |
parent | 5c68a006f173a75db1ac973dd45e2fe3945958f3 (diff) | |
parent | d20bbf4f3fe70ed3a00990b0ceb11292732318b8 (diff) | |
download | otp-7343ad05132654c2b5b8366d05991128a28a9a01.tar.gz otp-7343ad05132654c2b5b8366d05991128a28a9a01.tar.bz2 otp-7343ad05132654c2b5b8366d05991128a28a9a01.zip |
Merge branch 'bjorn/fix-on_load/OTP-8902' into maint-r14
* bjorn/fix-on_load/OTP-8902:
Teach -init_debug to print info about on_load handlers begin run
Fix hang in on_load handlers in embedded mode
Diffstat (limited to 'lib')
-rw-r--r-- | lib/kernel/src/kernel.erl | 7 | ||||
-rw-r--r-- | lib/kernel/test/code_SUITE_data/on_load_app-1.0/src/on_load_embedded.erl | 9 |
2 files changed, 16 insertions, 0 deletions
diff --git a/lib/kernel/src/kernel.erl b/lib/kernel/src/kernel.erl index 92ee7b441a..d3b0f6c712 100644 --- a/lib/kernel/src/kernel.erl +++ b/lib/kernel/src/kernel.erl @@ -143,6 +143,13 @@ init(safe) -> Boot = start_boot_server(), DiskLog = start_disk_log(), Pg2 = start_pg2(), + + %% Run the on_load handlers for all modules that have been + %% loaded so far. Running them at this point means that + %% on_load handlers can safely call kernel processes + %% (and in particular call code:priv_dir/1 or code:lib_dir/1). + init:run_on_load_handlers(), + {ok, {SupFlags, Boot ++ DiskLog ++ Pg2}}. get_code_args() -> diff --git a/lib/kernel/test/code_SUITE_data/on_load_app-1.0/src/on_load_embedded.erl b/lib/kernel/test/code_SUITE_data/on_load_app-1.0/src/on_load_embedded.erl index a39332f81d..b7fdd4d9ae 100644 --- a/lib/kernel/test/code_SUITE_data/on_load_app-1.0/src/on_load_embedded.erl +++ b/lib/kernel/test/code_SUITE_data/on_load_app-1.0/src/on_load_embedded.erl @@ -3,6 +3,15 @@ -on_load(run_me/0). run_me() -> + %% An onload handler typically calls code:priv_dir/1 + %% or code:lib_dir/1, so make sure that it works. + LibDir = code:lib_dir(on_load_app), + PrivDir = code:priv_dir(on_load_app), + LibDir = filename:dirname(PrivDir), + ModPath = code:which(?MODULE), + LibDir = filename:dirname(filename:dirname(ModPath)), + + %% Start a process to remember that the on_load was called. spawn(fun() -> register(everything_is_fine, self()), receive Any -> |