Closed
Description
Given the following code:
use git_tempfile::{ContainingDirectory, AutoRemove};
#[tokio::main]
async fn main() {
install_signal_handlers();
let _tempfile = git_tempfile::new("thetemp", ContainingDirectory::Exists, AutoRemove::Tempfile).unwrap();
futures::future::pending::<()>().await;
}
fn install_signal_handlers() {
use tokio::signal::unix::{signal, SignalKind};
let mut sigterm = signal(SignalKind::terminate()).unwrap();
let mut sigint = signal(SignalKind::interrupt()).unwrap();
tokio::spawn(async move {
futures::future::select(Box::pin(sigterm.recv()), Box::pin(sigint.recv())).await;
println!("got sigterm or sigint");
std::process::exit(5);
});
}
I would expect "got sigterm or sigint" to be printed on exit - and indeed that's what happens if I omit the _tempfile = ..
line. With the tempfile however the signal handler doesn't get called.
I can't tell if this is a bug in git-tempfile
, signal_hook
or tokio::signal
.
Note I'm using the following Cargo.toml
[package]
name = "tempfile-signals"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
git-tempfile = "^1.0.6"
tokio = { version = "1.2", features = [ "macros", "process", "signal", "time", "rt-multi-thread" ] }
futures = "^0.3.21"
Metadata
Metadata
Assignees
Labels
No labels