mpvrc/signal_hook_registry/index.html

42 lines
No EOL
8.9 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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-Regular-0fe48ade.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" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.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.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.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]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><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.2</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"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>signal_hook_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-793">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 dont build there, so tests need newer Rust version (they are run on
stable).</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 dont provide <code>register_sigaction</code> or <code>register_unchecked</code>.</li>
<li>Due to lack of signal blocking, theres a race condition.
After the call to <code>signal</code>, theres 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 theres 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><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.SigId.html" title="struct signal_hook_registry::SigId">SigId</a></div><div class="desc docblock-short">An ID of registered action.</div></li></ul><h2 id="constants" class="section-header">Constants<a href="#constants" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="constant" href="constant.FORBIDDEN.html" title="constant signal_hook_registry::FORBIDDEN">FORBIDDEN</a></div><div class="desc docblock-short">List of forbidden signals.</div></li></ul><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.register.html" title="fn signal_hook_registry::register">register</a><sup title="unsafe function"></sup></div><div class="desc docblock-short">Registers an arbitrary action for the given signal.</div></li><li><div class="item-name"><a class="fn" href="fn.register_sigaction.html" title="fn signal_hook_registry::register_sigaction">register_<wbr>sigaction</a><sup title="unsafe function"></sup></div><div class="desc docblock-short">Register a signal action.</div></li><li><div class="item-name"><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></div><div class="desc docblock-short">Register a signal action without checking for forbidden signals.</div></li><li><div class="item-name"><a class="fn" href="fn.register_unchecked.html" title="fn signal_hook_registry::register_unchecked">register_<wbr>unchecked</a><sup title="unsafe function"></sup></div><div class="desc docblock-short">Register a signal action without checking for forbidden signals.</div></li><li><div class="item-name"><a class="fn" href="fn.unregister.html" title="fn signal_hook_registry::unregister">unregister</a></div><div class="desc docblock-short">Removes a previously installed action.</div></li></ul></section></div></main></body></html>