blob: ab6843af286abd706b847f9d74c722397ad4c0f4 [file] [log] [blame]
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Backend of the signal-hook crate."><meta name="keywords" content="rust, rustlang, rust-lang, signal_hook_registry"><title>signal_hook_registry - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../normalize.css"><link rel="stylesheet" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../ayu.css" disabled><link rel="stylesheet" href="../dark.css" disabled><link rel="stylesheet" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="../crates.js"></script><script defer src="../main.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../signal_hook_registry/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../signal_hook_registry/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Crate signal_hook_registry</a></h2><div class="sidebar-elems"><ul class="block"><li class="version">Version 1.4.1</li><li><a id="all-types" href="all.html">All Items</a></li></ul><section><ul class="block"><li><a href="#structs">Structs</a></li><li><a href="#constants">Constants</a></li><li><a href="#functions">Functions</a></li></ul></section></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Crate <a class="mod" href="#">signal_hook_registry</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../src/signal_hook_registry/lib.rs.html#1-789">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Backend of the <a href="https://docs.rs/signal-hook">signal-hook</a> crate.</p>
<p>The <a href="https://docs.rs/signal-hook">signal-hook</a> crate tries to provide an API to the unix signals, which are a global
resource. Therefore, it is desirable an application contains just one version of the crate
which manages this global resource. But that makes it impossible to make breaking changes in
the API.</p>
<p>Therefore, this crate provides very minimal and low level API to the signals that is unlikely
to have to change, while there may be multiple versions of the <a href="https://docs.rs/signal-hook">signal-hook</a> that all use this
low-level API to provide different versions of the high level APIs.</p>
<p>It is also possible some other crates might want to build a completely different API. This
split allows these crates to still reuse the same low-level routines in this crate instead of
going to the (much more dangerous) unix calls.</p>
<h2 id="what-this-crate-provides"><a href="#what-this-crate-provides">What this crate provides</a></h2>
<p>The only thing this crate does is multiplexing the signals. An application or library can add
or remove callbacks and have multiple callbacks for the same signal.</p>
<p>It handles dispatching the callbacks and managing them in a way that uses only the
<a href="http://www.man7.org/linux/man-pages/man7/signal-safety.7.html">async-signal-safe</a> functions inside the signal handler. Note that the callbacks are still run
inside the signal handler, so it is up to the caller to ensure they are also
<a href="http://www.man7.org/linux/man-pages/man7/signal-safety.7.html">async-signal-safe</a>.</p>
<h2 id="what-this-is-for"><a href="#what-this-is-for">What this is for</a></h2>
<p>This is a building block for other libraries creating reasonable abstractions on top of
signals. The <a href="https://docs.rs/signal-hook">signal-hook</a> is the generally preferred way if you need to handle signals in your
application and provides several safe patterns of doing so.</p>
<h2 id="rust-version-compatibility"><a href="#rust-version-compatibility">Rust version compatibility</a></h2>
<p>Currently builds on 1.26.0 an newer and this is very unlikely to change. However, tests
require dependencies that don’t build there, so tests need newer Rust version (they are run on
stable).</p>
<h2 id="portability"><a href="#portability">Portability</a></h2>
<p>This crate includes a limited support for Windows, based on <code>signal</code>/<code>raise</code> in the CRT.
There are differences in both API and behavior:</p>
<ul>
<li>Due to lack of <code>siginfo_t</code>, we don’t provide <code>register_sigaction</code> or <code>register_unchecked</code>.</li>
<li>Due to lack of signal blocking, there’s a race condition.
After the call to <code>signal</code>, there’s a moment where we miss a signal.
That means when you register a handler, there may be a signal which invokes
neither the default handler or the handler you register.</li>
<li>Handlers registered by <code>signal</code> in Windows are cleared on first signal.
To match behavior in other platforms, we re-register the handler each time the handler is
called, but there’s a moment where we miss a handler.
That means when you receive two signals in a row, there may be a signal which invokes
the default handler, nevertheless you certainly have registered the handler.</li>
</ul>
</div></details><h2 id="structs" class="small-section-header"><a href="#structs">Structs</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.SigId.html" title="signal_hook_registry::SigId struct">SigId</a></div><div class="item-right docblock-short">An ID of registered action.</div></div></div><h2 id="constants" class="small-section-header"><a href="#constants">Constants</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="constant" href="constant.FORBIDDEN.html" title="signal_hook_registry::FORBIDDEN constant">FORBIDDEN</a></div><div class="item-right docblock-short">List of forbidden signals.</div></div></div><h2 id="functions" class="small-section-header"><a href="#functions">Functions</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.register.html" title="signal_hook_registry::register fn">register</a><sup title="unsafe function"></sup></div><div class="item-right docblock-short">Registers an arbitrary action for the given signal.</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.register_sigaction.html" title="signal_hook_registry::register_sigaction fn">register_sigaction</a><sup title="unsafe function"></sup></div><div class="item-right docblock-short">Register a signal action.</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.register_signal_unchecked.html" title="signal_hook_registry::register_signal_unchecked fn">register_signal_unchecked</a><sup title="unsafe function"></sup></div><div class="item-right docblock-short">Register a signal action without checking for forbidden signals.</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.register_unchecked.html" title="signal_hook_registry::register_unchecked fn">register_unchecked</a><sup title="unsafe function"></sup></div><div class="item-right docblock-short">Register a signal action without checking for forbidden signals.</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.unregister.html" title="signal_hook_registry::unregister fn">unregister</a></div><div class="item-right docblock-short">Removes a previously installed action.</div></div></div></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="signal_hook_registry" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html>