[erlang-questions] Intrusive function intercept

Vlad Dumitrescu vladdu55@REDACTED
Thu Oct 10 11:05:50 CEST 2013


Hi Tyron,

There is no way that a monitoring process can interrupt the execution of
the monitored process without its cooperation -- the simplest explanation
is that since monitoring involves sending a message to another process, the
current one continues running before the receiver even gets to check its
mailbox.

Besides introducing checks directly in your code, I can see two more
options:
4) interpret the code like the debugger does - this is not something I'd do
in a production setting
5) change your code to be "rule based": test() -> execute[fun x/0, fun y/0,
funz/0]. Then execute/1 can be a generic function that can do all kinds of
checks before and after each call. The advantage from #2 is that this
handling is in one place instead of spread over the codebase.

best regards,
Vlad



On Thu, Oct 10, 2013 at 10:54 AM, Tyron Zerafa <tyron.zerafa@REDACTED>wrote:

> Yes, we can change the code of the *test* function and use messages;
> however I was wondering whether there is another approach. Our idea is to
> build a resource access control system which authorizes access to
> resources. We came up with the following implementation options:
>  1) change the Erlang/OTP libraries - ruled out (not an option)
>  2) perform checks before each access - will have to change our current
> code and add these checks
>  3) using monitoring as described in the previous post - monitoring
> process performs checks and only allow processes to proceed if they've got
> the correct privilieges
>
> Tyron
>
>
> On Thu, Oct 10, 2013 at 10:02 AM, Tyron Zerafa <tyron.zerafa@REDACTED>wrote:
>
>> Hi,
>>
>>     I would like to monitor a process and suspend the execution of
>> certain functions to perform some other computation before. For instance
>> consider a process A which executing the following simple function.
>>
>> test() ->
>>     x(),
>>     y(),
>>     z().
>>
>> I would like to initiate a process, B, that monitors the execution of A.
>> I want B to:
>>   1) stop A before function y is executed
>>   2) execute some logic
>>   3) resumes the execution of A (by executing Y and Z)
>>
>> So far, I have been following this post<http://erlang.org/pipermail/erlang-questions/2003-January/006679.html>and managed to determine when the y() function call was being done, but
>> cannot suspend its execution. Any ideas how I can achieve this?
>>
>> Thanks
>> Tyron
>>
>
>
>
> --
> Best Regards,
> Tyron Zerafa
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20131010/329c718b/attachment.htm>


More information about the erlang-questions mailing list