<div dir="ltr">Hi Tyron,<div><br></div><div>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.</div>

<div><br></div><div>Besides introducing checks directly in your code, I can see two more options:</div><div>4) interpret the code like the debugger does - this is not something I'd do in a production setting</div><div>

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.</div>

<div><br></div><div>best regards,<br></div><div>Vlad</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Oct 10, 2013 at 10:54 AM, Tyron Zerafa <span dir="ltr"><<a href="mailto:tyron.zerafa@gmail.com" target="_blank">tyron.zerafa@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Yes, we can change the code of the <i>test</i> 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:<div>


 1) change the Erlang/OTP libraries - ruled out (not an option)</div><div> 2) perform checks before each access - will have to change our current code and add these checks <br></div><div> 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</div>


<div><br></div><div>Tyron</div></div><div class="gmail_extra"><div><div class="h5"><br><br><div class="gmail_quote">On Thu, Oct 10, 2013 at 10:02 AM, Tyron Zerafa <span dir="ltr"><<a href="mailto:tyron.zerafa@gmail.com" target="_blank">tyron.zerafa@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div>  </div><div>    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.</div>



<div><br></div><div>test() -></div><div>    x(),</div><div>    y(),</div><div>    z().</div><div><br></div><div>I would like to initiate a process, B, that monitors the execution of A. </div><div>I want B to:</div><div>



  1) stop A before function y is executed</div><div>  2) execute some logic</div><div>  3) resumes the execution of A (by executing Y and Z)</div><div><br></div><div>So far, I have been following <a href="http://erlang.org/pipermail/erlang-questions/2003-January/006679.html" target="_blank">this post</a> and managed to determine when the y() function call was being done, but cannot suspend its execution. Any ideas how I can achieve this? </div>



<div><br></div><div>Thanks</div><span><font color="#888888"><div>Tyron<br></div></font></span></div>
</blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br>Best Regards,<div>Tyron Zerafa</div>
</font></span></div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>