惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Jina AI
Jina AI
云风的 BLOG
云风的 BLOG
人人都是产品经理
人人都是产品经理
T
The Blog of Author Tim Ferriss
阮一峰的网络日志
阮一峰的网络日志
罗磊的独立博客
J
Java Code Geeks
博客园 - 聂微东
B
Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
WordPress大学
WordPress大学
腾讯CDC
L
LangChain Blog
Apple Machine Learning Research
Apple Machine Learning Research
Microsoft Azure Blog
Microsoft Azure Blog
D
DataBreaches.Net
The GitHub Blog
The GitHub Blog
美团技术团队
博客园 - Franky
Google DeepMind News
Google DeepMind News
V
V2EX
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
月光博客
月光博客
The Cloudflare Blog

The Rust Programming Language Forum - Latest topics

Beginner building a Rust backend framework (AI-assisted) — feedback appreciated C++ to Rust -- Exceptions Re-exporting a trait with a custom derive_macro Gold linker is deprecated Why is using PhantomData valid in this case? Code review for Static Pool Allocator Looking for a pool based allocator Why is this legal? What does it mean for Rustc to run "out of TLS keys"? Using async/await internally with no internal runtime, but exposing a nonblocking poll API — is this a reasonable design? Testing functions that use randomness `cargo-path`: improve coding agents&#39; ability to find Rust documentation Rust task runners Lifetime weird case Windows - USB device not detected A random rustc-ice-[...].txt file appeared Develop rust where the environment is setup in a docker Undefined Behavior: in-bounds pointer arithmetic failed: attempting to offset pointer by 20 bytes, but got alloc238 which is only 1 byte from the end of the allocation Unbug 0.5 - Runtime debug assertions Is there a tiny error in section 6.2 Reference types? Lifetime woes implementing ratatui::Widget for a reference Rusqlite + Chrono: How do I simplify code to obtain chrono datetime value From OOP to Rust – struggling with code organization and data structure design Way to avoid a self-referential struct Rust RF and audio resources/communities Whyhttp - HTTP mocks that fail where the bug actually is Using tokio channel permits in a tower service Arc::increment_strong_count design question (cross-post) `&T`, `&mut T`, `Pin<&mut T>` and `&Cell<T>`: Ways of Borrowing a `T` Ratatui detect arrow key press and release
Signal semantics for Rust
azalea_99 · 2026-04-21 · via The Rust Programming Language Forum - Latest topics
Hello everyone! Some operating systems have a concept of asynchronous signals -- an external events that can interrupt the control flow of a thread and cause it to execute a special function, called a signal handler . A control flow can be redirected into a signal handler from any point at which the signal is not blocked, which makes installing signal handlers very unsafe and requires caution while implementing a signal handler. C and C++ standards, as well as POSIX, specify what a signal is and what semantics they have, and what a signal handler can safely do. I wonder, are there signal semantics in Rust? Specifically, regarding: What functions from the standard library can be called from a signal handler? The Rust standard library is separated into three parts: core (language features), alloc (high-level interface to the memory allocator) and std (interaction with the operating system). As far as I understand, alloc and std shouldn't (generally) be assumed to be async-signal-safe. I wonder, which parts of core are safe for signal handlers and which are not? As far as I understand, panicking is not async-signal-safe because a panic handler may be async-signal-unsafe. I wonder, what about other parts, and specifically the formatting system ( core::fmt )? Allowed interactions with global objects. C and C++ allow signal handlers to only interact with global lock-free atomics and volatile sig_atomic_t objects. As far as I understand, the latter is a workaround for standards before C11 and C++11 (because such standards do not describe what an actual atomic variable is) and is thread-unsafe (it's still data race and undefined behavior if a signal handler from one thread assigns a global volatile sig_atomic_t and the other thread reads it at the same time). The proper way is to use atomics ( core::sync::atomic ). In Rust, there is no such thing as "non-lock-free atomics" (if there is no hardware support for atomic operations on certain type, then C or C++ compiler may emulate it with locking, while this is not allowed in Rust -- if there is no support for atomic operations on a certain integer type, then the corresponding atomic type is not provided) I also wonder about libc implementations that provide async-signal-safe thread-local variables (such as musl). Can Rust thread_local! variable be accessed from a signal handler if it's built with musl? What happens if a signal arrives while a thread-local Cell is in the process of being modified? 2 posts - 2 participants Read full topic