title: Signal Handler return and resume the program execution
body: <p>I am working on legacy application development which involves lot of signal handling and virtulization. I am facing difficult in understading the below mentioned scenario...</p>
  
  <h2>Program flow:</h2>
  
  <p>(A) SIGTRAP -> (B) Process -> (C) SIGTRAPHANDLER -> (D) foo() [functional implemented in libfoo] -> (E) message to kernel (thru NETLINK socket)  -> (F) RETURN</p>
  
  <pre><code>(A) is the sigtrap signal which is sent to process1 
  (B) is the normal user space process 
  (C) is the sigtrap handler invoked upon sigtrap signal 
  (D) foo() function is invoked under sigtrap handler and the function implemention is in libfoo library
  (E) Upon the invocation of foo() function , message is send to query x() data from kernel thru netlink socket
  (F) Successful message reply
  </code></pre>
  
  <p>here, at event (F) if the message reply is not received the process (B) is stalled forever which resulted in failure of all other processes which depends on (B). </p>
  
  <p>As far now, I attempted to break the signal using alarm() which didnt help to resume the program execution instead can treat alarm () only as recovery/cleanup stuff. </p>
  
  <p>Could someone help me on how the program execution can be recovered (within process B context) ?</p>
  
  <p>Sorry, if the explnation if not clear and precise. </p>
  
  <p>Platform : Linux, C</p>
  
  <pre><code>int main() {
  
  bind_sigtrap_hand(); 
  bind_sigalarm_hand();
  bind_handler_for_others();
  
  }
  
  bind_sigtrap_hand() {
  
  sa.sa_handler = invoke_me_sigtrap;
  if (sigaction(SIGTRAP, &amp;sa, NULL)  != 0)
  {
  //Error
  }
  }
  bind_sigalarm_hand() {
  
  sa.sa_handler = invoke_me_sigalarm;
  if (sigaction(TIMER_SIGNAL, &amp;sa, NULL)  != 0)
  {
  //Error
  }
  
  }
  
  void invoke_me_sigtrap(sig stuff)
  {
  
  if (SIGTRAP == sendsys){
  
  sendsyscall();
  
  }
  }
  </code></pre>
  
  <p>Here, in above example the sendsyscall () performs X action in kernel memory area which stalls frequently which is under sigtrap. Here , which kind of signal/alarm which help to resume the procees (without kill) to normal execution.</p>