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

feat: introduce KillSignal for sending signals to tasks #131

Merged
merged 8 commits into from
Nov 28, 2024

Conversation

dsherret
Copy link
Member

@dsherret dsherret commented Nov 28, 2024

This is a more advanced and appropriate form of a cancellation token.

For #33

@dsherret dsherret changed the title feat: introduce KillSignal for sending signals to tasks feat: introduce KillSignal for sending signals to tasks Nov 28, 2024
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, will this help with denoland/deno#18445?

src/shell/commands/executable.rs Show resolved Hide resolved
src/shell/commands/executable.rs Show resolved Hide resolved
#[tokio::test]
async fn listens_for_signals() {
if cfg!(windows) {
return; // signals are terrible on windows
Copy link
Member

Choose a reason for hiding this comment

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

🫠

Comment on lines 77 to 78
let _ = child.kill().await;
return ExecuteResult::Continue(signal.aborted_code(), Vec::new(), Vec::new());
Copy link
Member

Choose a reason for hiding this comment

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

Should we return the ExecuteResult with aborted code returned by child.kill() instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, let's do that.

@dsherret
Copy link
Member Author

LGTM, will this help with denoland/deno#18445?

Yes, I think so.

Copy link
Member

@littledivy littledivy left a comment

Choose a reason for hiding this comment

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

LGTM

TestBuilder::new()
.command(r#"deno eval 'Deno.addSignalListener("SIGINT", () => { console.log("interrupted!"); setTimeout(() => Deno.exit(0), 25); }); setInterval(() => {}, 1000)'"#)
.kill_signal(kill_signal)
.assert_exit_code(0) // signal was handled and a `Deno.exit(0)` was done
Copy link
Member Author

Choose a reason for hiding this comment

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

I improved the handling to return 0 in this case, which makes more sense because the signal was handled.

@dsherret dsherret merged commit af5d82e into denoland:main Nov 28, 2024
4 checks passed
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.

3 participants