-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
trap EXIT INT does not seem to work at all with CTRL-C #6649
Comments
I can reproduce, the bash script needs to be run as a script, not directly from the command line or else you engage job control. This should work in fish, I will figure out why it doesn't. |
In non-interactive mode, fish responds to a SIGINT-exited process by SIGINT itself. The function is enqueued but there's no place to execute it, fish is already exiting. I'll have to think about how this could work. |
I don't know if it's relevant, but I had noticed a change in behavior of the the Previously, executing the following and then hitting function stuffs --on-signal INT
echo hola
end As of 3.1.0, it doesn't. |
Heh, yes, we enqueue the event but refuse to execute it, because we're cancelling. |
Second issue bisects to f8ba0ac. |
It appears that non-interactive INT handlers have never worked in fish. The interactive case is a 3.1.0 regression and is fixed in bc702cc @zanchey this would be a good addition for 3.1.1, this comment is what is fixed. |
cherry-picked to 3.1.1 as f776c4e |
Note from the original post and #6744 this appears to have been broken in 3.0.0 as well. |
Moving this out of the 3.1.1 milestone as the non-interactive case is still not fixed. |
Note that trapping SIGINT or SIGTERM should prevent the shell from performing the default action (i.e. exit). At least there should be a way to tell fish not to exit (trap function return status?) |
I would really like to see this fixed, so I posted a bounty on this bug. |
When I use |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Huh, this actually works as expected if I attach a debugger and step through it. |
Er, you need to do a |
Fixed in cf2ca56 |
@bakhtiyarneyman I appreciate your offering a bounty but it is not necessary, please keep your money or donate it to a worthy cause. Thank you! |
On 3.5.1, the fix does not seem to work for custom fish-functions (defined in Example:
Calling It does work though if I define a simple script with the exact same Is it expected that this does not work for custom fish-functions? If so, what would be the proper workaround to use SIGINT with those? |
This very simple script does not print anything when I run it like
fish ./test-trap
and then press CTRL-C:If I run exactly the same script with bash and press CTRL-C, it prints
After
two times.It can be reproduced with a manual
function whatever --on-event fish_exit --on-signal INT
as well.Fish version: 3.0.2
Linux void 5.4.11-arch1-1 SMP PREEMPT Sun, 12 Jan 2020 12:15:27 +0000 x86_64 GNU/Linux
The text was updated successfully, but these errors were encountered: