45 lines
9.0 KiB
HTML
45 lines
9.0 KiB
HTML
<!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."><title>signal_hook_registry - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="signal_hook_registry" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.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]--><rustdoc-topbar><h2><a href="#">Crate signal_hook_registry</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../signal_hook_registry/index.html">signal_<wbr>hook_<wbr>registry</a><span class="version">1.4.8</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#what-this-crate-provides" title="What this crate provides">What this crate provides</a></li><li><a href="#what-this-is-for" title="What this is for">What this is for</a></li><li><a href="#rust-version-compatibility" title="Rust version compatibility">Rust version compatibility</a></li><li><a href="#portability" title="Portability">Portability</a></li></ul><h3><a href="#structs">Crate Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#constants" title="Constants">Constants</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>signal_<wbr>hook_<wbr>registry</span> <button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/signal_hook_registry/lib.rs.html#1-870">Source</a> </span></div><details class="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 class="doc-anchor" href="#what-this-crate-provides">§</a>What this crate provides</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 class="doc-anchor" href="#what-this-is-for">§</a>What this is for</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 class="doc-anchor" href="#rust-version-compatibility">§</a>Rust version compatibility</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>
|
||
<p>Note that this ancient version of rustc no longer compiles current versions of <code>libc</code>. If you
|
||
want to use rustc this old, you need to force your dependency resolution to pick old enough
|
||
version of <code>libc</code> (<code>0.2.156</code> was found to work, but newer ones may too).</p>
|
||
<h2 id="portability"><a class="doc-anchor" href="#portability">§</a>Portability</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="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.SigId.html" title="struct signal_hook_registry::SigId">SigId</a></dt><dd>An ID of registered action.</dd></dl><h2 id="constants" class="section-header">Constants<a href="#constants" class="anchor">§</a></h2><dl class="item-table"><dt><a class="constant" href="constant.FORBIDDEN.html" title="constant signal_hook_registry::FORBIDDEN">FORBIDDEN</a></dt><dd>List of forbidden signals.</dd></dl><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><dl class="item-table"><dt><a class="fn" href="fn.register.html" title="fn signal_hook_registry::register">register</a><sup title="unsafe function">⚠</sup></dt><dd>Registers an arbitrary action for the given signal.</dd><dt><a class="fn" href="fn.register_sigaction.html" title="fn signal_hook_registry::register_sigaction">register_<wbr>sigaction</a><sup title="unsafe function">⚠</sup></dt><dd>Register a signal action.</dd><dt><a class="fn" href="fn.register_signal_unchecked.html" title="fn signal_hook_registry::register_signal_unchecked">register_<wbr>signal_<wbr>unchecked</a><sup title="unsafe function">⚠</sup></dt><dd>Register a signal action without checking for forbidden signals.</dd><dt><a class="fn" href="fn.register_unchecked.html" title="fn signal_hook_registry::register_unchecked">register_<wbr>unchecked</a><sup title="unsafe function">⚠</sup></dt><dd>Register a signal action without checking for forbidden signals.</dd><dt><a class="fn" href="fn.unregister.html" title="fn signal_hook_registry::unregister">unregister</a></dt><dd>Removes a previously installed action.</dd></dl></section></div></main></body></html> |