I'm trying to write some code that will catch a signal like SIGTERM.
I found this and I also found How to handle blocking i/o in Rust, or long running external function calls in general.
But in the current Rust version (0.12 nightly) it seems like that std::io::signal::Listener
was removed. Did it get put somewhere else? If so can someone point me to how to catch a signal?
I believe that
std::io::signal
module was removed in this pull request. It is claimed that proper signals handling was never implemented properly for native runtime, so you likely wouldn't be able to use it now anyway. This seems to be a tracking issue for this problem.In the meantime, I think, you will have to drop down to the lowest-level unsafe functions from
libc
.At the time of writing this answer, there is an RFC for built-in signals.
I have had some success using the
chan-signal
crate: