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

signal-hook-tokio Windows build broken? #100

Open
davepacheco opened this issue Mar 10, 2021 · 5 comments
Open

signal-hook-tokio Windows build broken? #100

davepacheco opened this issue Mar 10, 2021 · 5 comments

Comments

@davepacheco
Copy link

I created a crate that's basically empty and depends on signal-hook and signal-hook-tokio:
https://github.com/davepacheco/signal-hook-windows-test/blob/main/Cargo.toml

I have GitHub Actions configured to build this on Ubuntu, Windows, and MacOS. The Ubuntu one works, but the Windows one failed. (The MacOS one was aborted because of the Windows failure.) I've only tested this once here, but I see the same behavior in a bigger crate that uses these crates.

The error is here:

   Compiling signal-hook-tokio v0.3.0
     Running `rustc --crate-name signal_hook_tokio --edition=2018 C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\signal-hook-tokio-0.3.0\src\lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg "feature=\"futures-core-0_3\"" --cfg "feature=\"futures-v0_3\"" -C metadata=3c6a7814b531fa0a -C extra-filename=-3c6a7814b531fa0a --out-dir D:\a\signal-hook-windows-test\signal-hook-windows-test\target\debug\deps -L dependency=D:\a\signal-hook-windows-test\signal-hook-windows-test\target\debug\deps --extern futures_core_0_3=D:\a\signal-hook-windows-test\signal-hook-windows-test\target\debug\deps\libfutures_core-a1626673b76c3bb9.rmeta --extern libc=D:\a\signal-hook-windows-test\signal-hook-windows-test\target\debug\deps\liblibc-aeda11fed0a8c75b.rmeta --extern signal_hook=D:\a\signal-hook-windows-test\signal-hook-windows-test\target\debug\deps\libsignal_hook-ac6b3a1d0c81f434.rmeta --extern tokio=D:\a\signal-hook-windows-test\signal-hook-windows-test\target\debug\deps\libtokio-a1fd3de27efaed30.rmeta --cap-lints allow`
error[E0433]: failed to resolve: could not find `iterator` in `signal_hook`
  --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\signal-hook-tokio-0.3.0\src\lib.rs:81:22
   |
81 | pub use signal_hook::iterator::backend::Handle;
   |                      ^^^^^^^^ could not find `iterator` in `signal_hook`

error[E0433]: failed to resolve: could not find `iterator` in `signal_hook`
  --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\signal-hook-tokio-0.3.0\src\lib.rs:82:18
   |
82 | use signal_hook::iterator::backend::{OwningSignalIterator, PollResult, SignalDelivery};
   |                  ^^^^^^^^ could not find `iterator` in `signal_hook`

error[E0433]: failed to resolve: could not find `iterator` in `signal_hook`
  --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\signal-hook-tokio-0.3.0\src\lib.rs:83:18
   |
83 | use signal_hook::iterator::exfiltrator::{Exfiltrator, SignalOnly};
   |                  ^^^^^^^^ could not find `iterator` in `signal_hook`

error[E0432]: unresolved import `tokio::net::UnixStream`
  --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\signal-hook-tokio-0.3.0\src\lib.rs:79:5
   |
79 | use tokio::net::UnixStream;
   |     ^^^^^^^^^^^^^^^^^^^^^^ no `UnixStream` in `net`

error[E0433]: failed to resolve: use of undeclared type `SignalDelivery`
   --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\signal-hook-tokio-0.3.0\src\lib.rs:115:21
    |
115 |         let inner = SignalDelivery::with_pipe(read, write, exfiltrator, signals)?;
    |                     ^^^^^^^^^^^^^^ use of undeclared type `SignalDelivery`

error[E0433]: failed to resolve: use of undeclared type `OwningSignalIterator`
   --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\signal-hook-tokio-0.3.0\src\lib.rs:116:17
    |
116 |         Ok(Self(OwningSignalIterator::new(inner)))
    |                 ^^^^^^^^^^^^^^^^^^^^ use of undeclared type `OwningSignalIterator`

error[E0433]: failed to resolve: use of undeclared type `PollResult`
   --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\signal-hook-tokio-0.3.0\src\lib.rs:153:13
    |
153 |             PollResult::Signal(sig) => Poll::Ready(Some(sig)),
    |             ^^^^^^^^^^ use of undeclared type `PollResult`

error[E0433]: failed to resolve: use of undeclared type `PollResult`
   --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\signal-hook-tokio-0.3.0\src\lib.rs:154:13
    |
154 |             PollResult::Closed => Poll::Ready(None),
    |             ^^^^^^^^^^ use of undeclared type `PollResult`

error[E0433]: failed to resolve: use of undeclared type `PollResult`
   --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\signal-hook-tokio-0.3.0\src\lib.rs:155:13
    |
155 |             PollResult::Pending => Poll::Pending,
    |             ^^^^^^^^^^ use of undeclared type `PollResult`

error[E0433]: failed to resolve: use of undeclared type `PollResult`
   --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\signal-hook-tokio-0.3.0\src\lib.rs:156:13
    |
156 |             PollResult::Err(error) => panic!("Unexpected error: {}", error),
    |             ^^^^^^^^^^ use of undeclared type `PollResult`

error[E0405]: cannot find trait `Exfiltrator` in this scope
  --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\signal-hook-tokio-0.3.0\src\lib.rs:92:27
   |
92 | pub struct SignalsInfo<E: Exfiltrator = SignalOnly>(OwningSignalIterator<UnixStream, E>);
   |                           ^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `SignalOnly` in this scope
  --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\signal-hook-tokio-0.3.0\src\lib.rs:92:41
   |
92 | pub struct SignalsInfo<E: Exfiltrator = SignalOnly>(OwningSignalIterator<UnixStream, E>);
   |                                         ^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `OwningSignalIterator` in this scope
  --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\signal-hook-tokio-0.3.0\src\lib.rs:92:53
   |
92 | pub struct SignalsInfo<E: Exfiltrator = SignalOnly>(OwningSignalIterator<UnixStream, E>);
   |                                                     ^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0405]: cannot find trait `Exfiltrator` in this scope
  --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\signal-hook-tokio-0.3.0\src\lib.rs:94:9
   |
94 | impl<E: Exfiltrator> SignalsInfo<E> {
   |         ^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `Handle` in this scope
   --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\signal-hook-tokio-0.3.0\src\lib.rs:123:29
    |
123 |     pub fn handle(&self) -> Handle {
    |                             ^^^^^^ not found in this scope

error[E0412]: cannot find type `SignalOnly` in this scope
   --> C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\signal-hook-tokio-0.3.0\src\lib.rs:132:32
    |
132 | pub type Signals = SignalsInfo<SignalOnly>;
    |                 -              ^^^^^^^^^^ not found in this scope
    |                 |
    |                 help: you might be missing a type parameter: `<SignalOnly>`

error: aborting due to 16 previous errors
@vorner
Copy link
Owner

vorner commented Mar 11, 2021

Windows is kind of a secondary platform, since its support of signals is very limited. Parts of the crate are not available there as a result. You can turn these parts off by default-features = false and picking only the things you need.

You're right that it probably should build with the defaults and just have them unavailable there. I'll get around to fixing that eventually, but probably not right now. I'd suggest you use the workaround above in the meantime, but if you want to get involved and fix it, I'll be happy for a PR.

Thanks for reporting it.

@davepacheco
Copy link
Author

No problem. I understand it's best-effort. My use case is very simple so I wound up using the ctrlc crate for now.

@vorner
Copy link
Owner

vorner commented Mar 22, 2021

I'm looking into it right now. The signal-hook with default features builds OK on windows (well, with some warnings about unused imports, but 🤷). But the signal-hook-tokio depends on the iterator feature and that one isn't ported to windows, so signal-hook-tokio is incompatible with windows.

I admit the error should be a bit better though, but I don't see a good way how to do it :-|.

@pickfire
Copy link
Contributor

https://github.com/helix-editor/helix/pull/464/checks?check_run_id=3093468552

We also get that on iterator, I think a workaround is remove signal-hook-tokio for windows.

joseluisq added a commit to static-web-server/static-web-server that referenced this issue Oct 29, 2021
@mediocregopher
Copy link

mediocregopher commented Nov 11, 2023

Tokio has a cross-platform ctrl-c signal handler, for those looking for a basic graceful shutdown feature: https://docs.rs/tokio/1.34.0/tokio/signal/fn.ctrl_c.html

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

No branches or pull requests

4 participants