I have run into a strange (and probably platform specific issue) when attempting to do a trap-sleep loop.
Specifically, the following code:
saysomething() {
trap saysomething 37
echo "Hello there"
while true; do
sleep 1
done
}
echo "Current pid: $$"
saysomething
prints "Hello there" everytime I send it a signal from another shell using kill -37 <pid>
on Ubuntu 14.04.
However, on an RHEL 7 machine, the above prints Hello there
the first time only. After that, the script keeps executing but fails to respond to any more signals.
What could be the reason for this difference?
Not really an answer, but this is the workaround I ended up using the following as a workaround:
I still can't explain the reason for this difference in behaviour though.