-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add win interruption using tokio::windows for spk_monitor #1110
base: main
Are you sure you want to change the base?
Conversation
87c2486
to
1528637
Compare
@@ -86,11 +89,10 @@ impl CmdMonitor { | |||
rt.block_on(self.wait_for_ready()); | |||
// clean up this runtime and all other threads before detaching | |||
drop(rt); | |||
|
|||
#[cfg(unix)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this working for you? I think the monitor still needs to be background-ed to not block the runtime from launching, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you mean under windows?
So far i was able to trig the commands of course with error but not depending of the runtime blocking
#[cfg(unix)] | ||
let mut interrupt = signal(SignalKind::interrupt()) | ||
.map_err(|err| Error::process_spawn_error("signal()", err, None))?; | ||
#[cfg(windows)] | ||
let mut interrupt = | ||
ctrl_c().map_err(|err| Error::process_spawn_error("ctrl_c()", err, None))?; | ||
#[cfg(unix)] | ||
let mut quit = signal(SignalKind::quit()) | ||
.map_err(|err| Error::process_spawn_error("signal()", err, None))?; | ||
#[cfg(windows)] | ||
let mut quit = ctrl_c().map_err(|err| Error::process_spawn_error("ctrl_c()", err, None))?; | ||
#[cfg(unix)] | ||
let mut terminate = signal(SignalKind::terminate()) | ||
.map_err(|err| Error::process_spawn_error("signal()", err, None))?; | ||
#[cfg(windows)] | ||
let mut terminate = | ||
ctrl_c().map_err(|err| Error::process_spawn_error("ctrl_c()", err, None))?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid all this #[cfg]
maybe we can create a single future to wrap all the signals -
specifically, define a trait with a function that builds a future for all signals in one that can be implemented differently on this CmdMonitor
type for each os. Let me know if my description is not clear
1528637
to
5f9133f
Compare
Signed-off-by: Philippe Llerena <[email protected]>
5f9133f
to
09288f6
Compare
I switch back to draft. I need further test. |
This PR add support for Windows interruption signal using ctrl-c based on
tokio::signal::windows::ctrl_c
I alternate unix/win to streamline comparaison but i can reorg to regroup by OS.