Skip to content

Conversation

remimimimimi
Copy link
Contributor

@remimimimimi remimimimimi commented Sep 10, 2025

Should fix #4426, but won't solve the problem completely.

We have the following cases:

  • In an interactive TTY, the terminal sends SIGINT to the foreground process group.
  • In non‑TTY (CI/pipes), the terminal doesn’t deliver SIGINT.
  • Windows quirk: Ctrl+C can terminate the parent; we must consume it so only the child handles the console event.
  • In interactive runs where the child is in a different process group, the terminal won’t signal the child at all unless the parent forwards.

This PR fixes the first two cases; the third case already had a solution, leaving the fourth. To solve it, we should get PGID of the subprocess (using its PID), but I'm not aware of a way to do this with deno_task_shell. After spending some time looking through its code base, I couldn't figure out any proper way to implement this, so postponed complete solution.

@remimimimimi remimimimimi force-pushed the fix/cli-ctrl+c-sent-twice branch from e9451ed to f4a3c1b Compare September 10, 2025 08:54
@lucascolley lucascolley added bug Something isn't working cli Issue related to CLI area:run Related to pixi run labels Sep 10, 2025
@remimimimimi remimimimimi force-pushed the fix/cli-ctrl+c-sent-twice branch from f4a3c1b to 6cb1e2a Compare September 10, 2025 13:09
Copy link
Contributor

@nichmor nichmor left a comment

Choose a reason for hiding this comment

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

look good to me at the first glance - will play with it tomorrow.

I wonder, do we need a separate test for this?

@Hofer-Julian
Copy link
Contributor

Hofer-Julian commented Sep 11, 2025

I wonder, do we need a separate test for this?

Yes, it would be good to make a test out of the nice reproducer in #4426.

If the difference, between non-TTY (CI) and TTY makes this too annoying, I'd be okay with leaving the test for now

Copy link
Contributor

@Hofer-Julian Hofer-Julian left a comment

Choose a reason for hiding this comment

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

I can confirm that this fixes the reproducer

@uwu-420
Copy link

uwu-420 commented Sep 16, 2025

I just tried this fix on my example from #4532 (comment) and it worked as expected, I only got one SIGINT 👍

Copy link
Contributor

@Hofer-Julian Hofer-Julian left a comment

Choose a reason for hiding this comment

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

Thanks Valentin!

@Hofer-Julian Hofer-Julian merged commit e9b3d87 into prefix-dev:main Sep 16, 2025
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:run Related to pixi run bug Something isn't working cli Issue related to CLI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(cli): Ctrl+C sent twice

5 participants