Signal Handling in UNIX


After registering to handle a signal. In the signal handler function is it necessary to call signal() again to re-register?


Check <a href="https://stackoverflow.com/questions/4863420/signal-handling/4864889#4864889" rel="nofollow">this</a> answer. Or particularly <a href="http://users.evtek.fi/~tk/rtp/signals-programming.html" rel="nofollow">this</a> link. Basically it depends on the model (BSD or System V) your unix system follows.

Extract from signal man page.


In the original Unix systems, when a handler that was established using signal() was invoked by the delivery of a signal, the disposition of the signal would be reset to SIG_DFL, and the system did not block delivery of further instances of the signal. System V also provides these semantics for signal(). This was bad because the signal might be delivered again before the handler had a chance to reestablish itself. Furthermore, rapid deliveries of the same signal could result in recursive invocations of the handler.

BSD improved on this situation by changing the semantics of signal handling (but, unfortunately, silently changed the semantics when establishing a handler with signal()). On BSD, when a signal handler is invoked, the signal disposition is not reset, and further instances of the signal are blocked from being delivered while the handler is executing.

The situation on Linux is as follows:

<ul><li>The kernel's signal() system call provides System V semantics. </li> <li>By default, in glibc 2 and later, the signal() wrapper function does not invoke the kernel system call. Instead, it calls sigaction(2) using flags that supply BSD semantics. This default behavior is provided as long as the _BSD_SOURCE feature test macro is defined. By default, _BSD_SOURCE is defined; it is also implicitly defined if one defines _GNU_SOURCE, and can of course be explicitly defined.<br /> On glibc 2 and later, if the _BSD_SOURCE feature test macro is not defined, then signal() provides System V semantics. (The default implicit definition of _BSD_SOURCE is not provided if one invokes gcc(1) in one of its standard modes (-std=xxx or -ansi) or defines various other feature test macros such as _POSIX_SOURCE, _XOPEN_SOURCE, or _SVID_SOURCE; see feature_test_macros(7).)</li> <li>The signal() function in Linux libc4 and libc5 provide System V semantics. If one on a libc5 system includes instead of , then signal() provides BSD semantics.</li> </ul></blockquote>


  • how read-through work in ignite
  • how C++ Implicitly convert c style string to a string object?
  • Why would I extend java.lang.RuntimeException
  • Ambiguity in c++ constructor when a constructor with default argument exists
  • How to re-run property evaluation in MSBuild target?
  • Dynamic Bytecode Instrumentation fails without any error
  • Converting JsonNode to java array
  • jquery sending data with escapes?
  • What's the difference between using a heading tag and a large font in a tag?
  • Using R to write a .mat file not giving the right output?
  • When does initialisation of global variables happen?
  • how to create trigger to do concatenation of fields
  • Exclusive access established by another Thread Java smartcardio
  • How can I get the maximum number of OpenMP threads that may be created during the whole execution of
  • Displaying pdf files using the PDFKit interface
  • Python Paramiko send CTRL+C to an ssh shell
  • How to extract a number from a string [duplicate]
  • How can I count unique terms in a plaintext file case-insensitively?
  • LNK1104: cannot open file 'kernel32.lib'
  • Does the Azure table storage API cache results?
  • Invert string in Rust
  • Javascript focus remove text highlight
  • Responsive left sidebar open close
  • Prevent page break in text block with iText, XMLWorker
  • Less Conflicting Session Manager for Zope 2
  • PushKit for VOIP iOS apps
  • C++ friend class std::vector
  • Rest Services conventions
  • SyntaxError: (irb):26: both block arg and actual block given
  • Multiple producers single consumer locking schema
  • Tell Git to stop prompting me for conflicts when none really exist?
  • Overlapping controls in Windows XP
  • calculate gradient output for Theta update rule
  • Assign variable to the value in HTML
  • Ensure fsync did its job
  • PHP buffered output depending on server setting?
  • Bad request using file_get_contents for PUT request in PHP
  • Android Studio and gradle
  • SQL merge duplicate rows and join values that are different
  • Java static initializers and reflection