有没有办法在 Windows 上收听信号 [英] Is there a way to listen to signals on Windows
问题描述
我正在用 Rust 为 Windows 编写一个小 shell,并且想要终止我生成的 Command
并阻止我的 shell 退出.
I'm writing a small shell for Windows in Rust, and want to kill the Command
I spawned and prevent my shell from quitting.
有没有办法在 Rust 中捕获 Windows SIGINT
等价物?
Is there a way of capturing the Windows SIGINT
equivalent in Rust?
推荐答案
有 一个 crate, chan-signal
,旨在通过生成一个线程并让它等待信号来帮助处理这个问题.
There is a crate, chan-signal
, that aims to help in handling this, by spawning a thread and having it wait for signals.
目前不支持 Windows.
It doesn't currently support windows.
一个 RFC 要求将此功能集成到语言的标准库,但它非常年轻.
There is an RFC asking for this functionality to be integrated into the language's standard library, but it is very young.
看来您的选择是与 FFI 合作.
It seems your option is to go with FFI.
这篇关于有没有办法在 Windows 上收听信号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!