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

Request: a way of catching any windows signal. #4921

Closed
jkelleyrtp opened this issue Aug 17, 2022 · 4 comments
Closed

Request: a way of catching any windows signal. #4921

jkelleyrtp opened this issue Aug 17, 2022 · 4 comments
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-signal Module: tokio/signal

Comments

@jkelleyrtp
Copy link
Contributor

Right now it seems that tokio only exports signal handlers for ctrl_c and ctrl_break for windows, while for Unix, you can trap any signal covered by SignalKind.

It would be great if there was a method that would allow creating an RxFuture for any of the signal types in the winapi crate.

This method already exists, but it's marked private. It would be great if this were public and given a new name so I could trap the various other windows signals that exist.

fn new(signum: DWORD) -> io::Result<RxFuture> {

@jkelleyrtp jkelleyrtp added A-tokio Area: The main tokio crate C-feature-request Category: A feature request. labels Aug 17, 2022
@Noah-Kennedy
Copy link
Contributor

I don't have any issues with doing this, but I'd like to know why it's marked as private first.

@ipetkov
Copy link
Member

ipetkov commented Aug 18, 2022

but I'd like to know why it's marked as private first.

@Noah-Kennedy just to start out with a conservative API surface and no one has asked for it until now 😄

@jkelleyrtp which signals are you interested in receiving?

I see win API has other events like CTRL_CLOSE_EVENT/CTRL_LOGOFF_EVENT/CTRL_SHUTDOWN_EVENT we can easily add these in as a concrete public API. I'm not philosophically opposed to having more of a general signal solution like we do on Unix platforms, though I'm not very familiar with the windows signal semantics and if they are analogous to the Unix ones

@ipetkov ipetkov added the M-signal Module: tokio/signal label Aug 18, 2022
@schultetwin1
Copy link
Contributor

The only event we need for now is CTRL_CLOSE_EVENT. CTRL_LOGFF_EVENT and CTRL_SHUTDOWN_EVENT can be added as well but if you want to keep with the them of a conservative API, we'd be happy with just CTRL_CLOSE_EVENT.

@jkelleyrtp
Copy link
Contributor Author

I'll put up a branch here in a sec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-signal Module: tokio/signal
Projects
None yet
Development

No branches or pull requests

4 participants