title: Checking for installed signal handler
body: <p>I have a library which installs a signal handler for SIGSEGV for debugging purpose. The SIGSEGV handler just prints some information and then exits the program.</p>
  
  <p>Recently, I had the need to invoke this library from Java (using JNI), and the problem I ran into is that JVM also installs a signal handler for SIGSEGV for more useful purpose than mine. </p>
  
  <p>So the action what I want to choose is that in case my library finds a signal handler already installed for a signal, it simply doesn't install any signal.</p>
  
  <p>For clarity, I am using sigaction call.</p>
  
  <p>Now to achieve my functionality what I have to do is:</p>
  
  <p>a. BLOCK all signals.</p>
  
  <p>b. call sigaction and check if oact returns a valid handler.</p>
  
  <p>c. if it does, re-call sigaction with oact as new act.</p>
  
  <p>d. UNBLOCK signals.</p>
  
  <p>B and c seem to be cumbersome to me. What I want is to be able to just determine if a particular signal already has a handler without first replacing the handler and then re-replacing it with the original handler (achieving nothing).</p>
  
  <p>Is there anything more granular than sigaction?</p>