Skip to content
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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

doubleailes
Copy link
Contributor

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.

@doubleailes doubleailes changed the title add win interruption using tokio::windows add win interruption using tokio::windows for spk_monitor Aug 20, 2024
@doubleailes doubleailes force-pushed the support_windows_spk_monitor branch 3 times, most recently from 87c2486 to 1528637 Compare September 4, 2024 08:38
@@ -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)]
Copy link
Collaborator

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?

Copy link
Contributor Author

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

Comment on lines 147 to 163
#[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))?;
Copy link
Collaborator

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

@doubleailes doubleailes force-pushed the support_windows_spk_monitor branch from 1528637 to 5f9133f Compare September 11, 2024 13:06
@doubleailes doubleailes force-pushed the support_windows_spk_monitor branch from 5f9133f to 09288f6 Compare September 11, 2024 13:09
@doubleailes doubleailes marked this pull request as draft September 12, 2024 12:09
@doubleailes
Copy link
Contributor Author

I switch back to draft. I need further test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants