<div dir="ltr">On Sun, Mar 31, 2013 at 8:33 PM, Rahul Gandhi <span dir="ltr"><<a href="mailto:rahul.rahulgags@gmail.com" target="_blank">rahul.rahulgags@gmail.com</a>></span> wrote:<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div>As per my understanding, when the signal denoted by signum occurs/is raised, the action is taken which can be either <span style="font-size:medium;font-family:monospace">SIG_DFL, </span><span style="font-size:medium;font-family:monospace">SIG_IGN or a function/handler</span><span><font face="arial, helvetica, sans-serif"><font size="3">. </font>What i don't understand is, when we write for example </font></span><font face="arial, helvetica, sans-serif" color="#000000">signal(SIGPROF, handler); isn't this supposed to be asynchronous? however the code is executed sequentially. So, when this function is encountered, it is executed and when a signal is raised, how does it know what to do?<br>
</font></div></div></blockquote><div><br>signal() in your example lets the operating system know that you want the function 'handler' to be executed if SIGPROF is raised and delivered to your process; it doesn't call the handler when that line of code is executed.<br>
<br>~Yousef<br><br></div></div></div>