Lines Matching full:signal
27 #include <signal.h>
50 // libsigchain provides an interception layer for signal handlers, to allow ART and others to give
51 // their signal handlers the first stab at handling signals before passing them on to user code.
53 // It implements wrapper functions for signal, sigaction, and sigprocmask, and a handler that
56 // In our handler, we start off with all signals blocked, fetch the original signal mask from the
57 // passed in ucontext, and then adjust our signal mask appropriately for the user handler.
61 // SA_NODEFER: unimplemented, we can manually change the signal mask appropriately.
64 // ~SA_RESTART: unimplemented, maybe we can reserve an RT signal, register an empty handler that
65 // doesn't have SA_RESTART, and raise the signal to avoid restarting syscalls that are
128 fatal("Unable to find next %s in signal chain", name);
198 // Register the signal chain with the kernel if needed.
255 fatal("too many special signal handlers");
287 // _NSIG is 1 greater than the highest valued signal, but signals start from 1.
300 // The native bridge signal handler might not return.
320 // Forward to the user's signal handler.
347 fatal("exiting due to SIG_DFL handler for signal %d", signo);
355 static int __sigaction(int signal, const SigactionType* new_action,
359 // If this signal has been claimed as a signal chain, record the user's
361 // Note that we check that the signal number is in range here. An out of range signal
363 if (signal <= 0 || signal >= _NSIG) {
368 if (chains[signal].IsClaimed()) {
369 SigactionType saved_action = chains[signal].GetAction<SigactionType>();
371 chains[signal].SetAction(new_action);
379 // Will only get here if the signal chain has not been claimed. We want
381 return linked(signal, new_action, old_action);
384 extern "C" int sigaction(int signal, const struct sigaction* new_action,
387 return __sigaction(signal, new_action, old_action, linked_sigaction);
391 extern "C" int sigaction64(int signal, const struct sigaction64* new_action,
394 return __sigaction(signal, new_action, old_action, linked_sigaction64);
398 extern "C" sighandler_t signal(int signo, sighandler_t handler) {
412 // If this signal has been claimed as a signal chain, record the user's
421 // Will only get here if the signal chain has not been claimed. We want
434 return signal(signo, handler);
441 // When inside a signal handler, forward directly to the actual sigprocmask.
452 // Don't allow claimed signals in the mask. If a signal chain has been claimed
453 // we can't allow the user to block that signal.
480 extern "C" void AddSpecialSignalHandlerFn(int signal, SigchainAction* sa) {
483 if (signal <= 0 || signal >= _NSIG) {
484 fatal("Invalid signal %d", signal);
488 chains[signal].AddSpecialHandler(sa);
489 chains[signal].Claim(signal);
492 extern "C" void RemoveSpecialSignalHandlerFn(int signal, bool (*fn)(int, siginfo_t*, void*)) {
495 if (signal <= 0 || signal >= _NSIG) {
496 fatal("Invalid signal %d", signal);
499 chains[signal].RemoveSpecialHandler(fn);
502 extern "C" void EnsureFrontOfChain(int signal) {
505 if (signal <= 0 || signal >= _NSIG) {
506 fatal("Invalid signal %d", signal);
511 linked_sigaction(signal, nullptr, ¤t_action);
517 chains[signal].Register(signal);