'Tokio signal::ctrl_c failing over ssh
My Code currently looks like this:
// spawn threads
let handle_1 = tokio::spawn(...);
let handle_2 = tokio::spawn(...);
// this thread later starts a rocket.rs server
let handle_3 = tokio::spawn(...);
// handle ctrl+c
let h_signal = tokio::spawn(async move {
match signal::ctrl_c().await {
Ok(()) => {
// shutdown
...
}
Err(_) => {
// shutdown
...
}
}
// save data
...
});
let _ = tokio::join!(handle_1, handle_1, handle_1, h_signal);
This code works perfectly on Windows and Linux, but if I run it on a VPS which I connect to with ssh, this code suddenly stops works. By stops working I mean:
- The rocket.rs server does not start
- When I hit ctrl+c the program just exits without the shutdown code being called
Anyone got an Idea on why this might happen?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
