trap is not executed when interrupting a sleep command
Nobody has claimed this yet.
- Dominant language
- CSS
- Stars
- 3.3k
- Forks
- 446
- Avg merge
- 2h 16m
- Merged PRs (30d)
- 1
Description
In my .bashrc file I have the following
function cleanup() {
echo "Global cleanup"
for i in {1..2}; do
echo $i
sleep 1
done
}
trap cleanup SIGINT
function infinite_loop() {
local i=1
while true; do
echo "hello $i"
i=$((i + 1))
sleep 1
done
}
I basically want to execute some cleanup code after typing Ctrl+c
If I type Ctrl+c in a msys shell the trap correctly works but if I run the infinite_loop function and then type Ctrl+c the cleanup code is not executed also if the infinite_loop is stopped.
I tried also to add the option:
MSYS=enable_pcon
in the .minttyrc file after reading this: https://github.com/mintty/mintty/issues/56#issuecomment-1962490572 without success.
The version is msys2-runtime 3.4.10-5
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the behavior from the .bashrc example in an MSYS shell, comparing the SIGINT trap directly with the infinite_loop function and its sleep commands. Check the reported msys2-runtime 3.4.10-5 version and the linked mintty discussion first; done means determining why Ctrl+C does not execute cleanup and documenting or resolving the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100