Im trying to detect when my menu is resized using trap "echo resized" SIGWINCH but it doesnt seem to be detecting it. Im currently using ubuntu 20.04 and i am using a bash script to do this.
The trap command is at the top of my script. Why is it not executing?
Asked
Active
Viewed 269 times
-1
Quantum
- 29
- 5
-
try removing the `SIG` prefix as: `trap 'echo resized' WINCH`. Tested it working with `gnome-terminal` and `xterm`. – Léa Gris Nov 07 '20 at 14:35
1 Answers
3
According to bash manual (man bash):
If bash is waiting for a command to complete and receives a signal for which a trap has been set, the trap will not be executed until the command completes.
You can verify this with:
trap 'echo resized' SIGWINCH
while true; do
sleep 1
done
pynexj
- 16,531
- 5
- 29
- 48
-
See: https://stackoverflow.com/questions/27694818/interrupt-sleep-in-bash-with-a-signal-trap – Léa Gris Nov 07 '20 at 14:44