Skip to content

fix: forward CTRL+C signal to deno_task_shell#4243

Merged
baszalmstra merged 10 commits intoprefix-dev:mainfrom
wolfv:ctrl-c-deno-task-shell
Aug 1, 2025
Merged

fix: forward CTRL+C signal to deno_task_shell#4243
baszalmstra merged 10 commits intoprefix-dev:mainfrom
wolfv:ctrl-c-deno-task-shell

Conversation

@wolfv
Copy link
Member

@wolfv wolfv commented Jul 31, 2025

I cleaned up my previous work and this should fix #3789

I'll look into forwarding more signals (like SIGHUP etc.)

@lucascolley lucascolley added bug Something isn't working cli Issue related to CLI area:run Related to pixi run labels Jul 31, 2025
@lucascolley lucascolley changed the title fix: forward CTRL+C signal to deno_task_shell fix: forward CTRL+C signal to deno_task_shell Jul 31, 2025
@ruben-arts
Copy link
Contributor

ruben-arts commented Jul 31, 2025

Can we get this tested on all platforms?

This was an issue I ran into last time: #3837 (comment)

@ruben-arts
Copy link
Contributor

Using the example in the issue this doesn't allow me to correctly stop the pixi process anymore.

import signal
import time

def signal_handler(signum, frame):
    print(f"Signal handler called with signal {signum}")

signal.signal(signal.SIGINT, signal_handler)

while True:
    time.sleep(1)

This will run indefinitely without me being able to stop it. While the old pixi allows me to send ctrl+z to suspend it.

I think we also have to deal with ctrl+z(SIGSTP).

@baszalmstra
Copy link
Contributor

Oke so I did a bit of a deepdive. Pixi doesnt listen to either SIGKILL or SIGSTOP because we want the OS to handle that for us (e.g. suspend or kill the process). However, when SIGSTOP is send to the pixi process it will be suspended but the child process will not. I see no way around this except for running the child processes in the same process group, but I dont know if thats possible with deno_task_shell.

Using ctrl+z in the way you described is also weird @ruben-arts . What you are effectively doing is sending the process to the background, it remains alive and will keep consuming resources. A better approach would be to use ctrl+\ to terminate the process.

I would be in favour of leaving this limitation as is for now, and merging this PR. I think it solves way more problems than it introduces.

@wolfv
Copy link
Member Author

wolfv commented Aug 1, 2025

I also did a deep dive - and SIGSTOP and SIGTSTP (CTRL+Z) are different. I guess what we could do is we could send SIGTSTP to the child process, unset the listener, re-send SIGTSTP to the pixi process. Then, on SIGCONT do the reverse.

I don't really know whether that's worth it though. Seems like a pretty heavy complication.

@wolfv
Copy link
Member Author

wolfv commented Aug 1, 2025

@ruben-arts the test is fixed and ran on Unix.

@baszalmstra idk if we could test this easily on Windows?

IMO we can merge this.

@baszalmstra baszalmstra merged commit 2f25603 into prefix-dev:main Aug 1, 2025
39 checks passed
@jonashaag
Copy link

Thanks! <3

@jonashaag
Copy link

jonashaag commented Nov 24, 2025

It looks like this is broken again. kill -INT is not received by the child process, reproducible with the example above. Only Ctrl+C is received.

@wolfv
Copy link
Member Author

wolfv commented Nov 24, 2025

@jonashaag but it worked for some time?

@jonashaag
Copy link

Not sure! I tried to remove my hacks just now and it looks like I'll have to keep them for now

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.

Signals not forwarded to child processes

5 participants