Skip to content

Remove dependency on signal-hook-tokio#387

Merged
mxpv merged 1 commit intocontainerd:mainfrom
jprendes:remove-signal-hook
Apr 10, 2025
Merged

Remove dependency on signal-hook-tokio#387
mxpv merged 1 commit intocontainerd:mainfrom
jprendes:remove-signal-hook

Conversation

@jprendes
Copy link
Contributor

@jprendes jprendes commented Apr 8, 2025

The signal-hook-tokio package is now integrated into tokio in the signals feature.
Moreover, the signal-hook-tokio crates is unix only (see vorner/signal-hook#100 (comment)), while the tokio impl also supports windows.

This PR is part of the effort to add Windows support for the async feature.

@github-actions github-actions bot added the C-shim Containerd shim label Apr 8, 2025
@jprendes
Copy link
Contributor Author

jprendes commented Apr 8, 2025

@mxpv @jsturtevant PTAL, thanks!

Copy link
Contributor

@jsturtevant jsturtevant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

use futures::stream::poll_fn;
poll_fn(move |cx| -> Poll<Option<i32>> {
ready!(sig.poll_recv(cx));
Poll::Ready(Some(kind.as_raw_value()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand this part. Why do we poll manually here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The object returned by signal is not a Stream. The poll_fn function constructs a Stream based on a polling function.
We need to create a Stream so that we can use the SelectAll stream "merge" all the signal streams.

I'll add this as a comment in the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative would be to use tokio-stream's wrappers for Signals and CtrlC: https://docs.rs/tokio-stream/latest/tokio_stream/wrappers/struct.SignalStream.html

I don't think it's worth adding a new dependency when poll_fn works fine, but it would be a clearer without having to add a comment.

Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com>
@jprendes jprendes force-pushed the remove-signal-hook branch from c5cc38c to 55e25d4 Compare April 8, 2025 14:21
@jprendes jprendes closed this Apr 8, 2025
@jprendes jprendes reopened this Apr 8, 2025
@jprendes
Copy link
Contributor Author

jprendes commented Apr 8, 2025

Looks like there are some unrelated issues with the Ubuntu 20.04 runners.
It fails even before starting the workflow.

This is a scheduled Ubuntu 20.04 brownout. Ubuntu 20.04 LTS runner will be removed on 2025-04-15. For more details, see actions/runner-images#11101


GitHub Actions has encountered an internal error when running your job.

Is there any specific reason to test on Ubuntu 20.04?

@jprendes jprendes closed this Apr 9, 2025
@jprendes jprendes reopened this Apr 9, 2025
@jprendes jprendes closed this Apr 9, 2025
@jprendes jprendes reopened this Apr 9, 2025
@jprendes jprendes requested a review from mxpv April 9, 2025 19:56
@mxpv mxpv added this pull request to the merge queue Apr 10, 2025
Merged via the queue into containerd:main with commit 8130e41 Apr 10, 2025
63 of 72 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-shim Containerd shim

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants