diff options
author | Björn Gustavsson <[email protected]> | 2012-08-06 11:54:04 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2012-08-06 12:06:22 +0200 |
commit | c595aff5bd41a5d392145212606c87e40779e142 (patch) | |
tree | 2cdda7c84a0b138643d7586828b41b8593fb85c2 /lib/compiler/src/compile.erl | |
parent | 85a5f71087785c4eada6a4101ffeef6a15f5c409 (diff) | |
download | otp-c595aff5bd41a5d392145212606c87e40779e142.tar.gz otp-c595aff5bd41a5d392145212606c87e40779e142.tar.bz2 otp-c595aff5bd41a5d392145212606c87e40779e142.zip |
compiler: Eliminate EXIT messages from the temporary compiler process
If a process trap exits, calling the compiler would leave an EXIT
message in the message queue of the calling process because the
compiler spawns a temporary work process. Eliminate the EXIT process
by monitoring the temporary process instead of linking to it.
Reported-by: Jeremy Heater
Diffstat (limited to 'lib/compiler/src/compile.erl')
-rw-r--r-- | lib/compiler/src/compile.erl | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl index 7911f51a73..7365706b94 100644 --- a/lib/compiler/src/compile.erl +++ b/lib/compiler/src/compile.erl @@ -146,10 +146,17 @@ env_default_opts() -> do_compile(Input, Opts0) -> Opts = expand_opts(Opts0), - Self = self(), - Serv = spawn_link(fun() -> internal(Self, Input, Opts) end), + {Pid,Ref} = + spawn_monitor(fun() -> + exit(try + internal(Input, Opts) + catch + error:Reason -> + {error,Reason} + end) + end), receive - {Serv,Rep} -> Rep + {'DOWN',Ref,process,Pid,Rep} -> Rep end. expand_opts(Opts0) -> @@ -242,11 +249,6 @@ format_error({module_name,Mod,Filename}) -> errors=[], warnings=[]}). -internal(Master, Input, Opts) -> - Master ! {self(), try internal(Input, Opts) - catch error:Reason -> {error, Reason} - end}. - internal({forms,Forms}, Opts0) -> {_,Ps} = passes(forms, Opts0), Source = proplists:get_value(source, Opts0, ""), |