I have a script (flexblocks) that prints a status of my system every second. So that I can pipe it into lemonbar. It looks like this:
#!/bin/sh
main() {
while true; do
sleep "1s" // This
// ...
printf '%s\n' "some status here"
done
}
refresh() {
unset "$@"
}
trap "refresh node" "USR1"
trap "refresh pmix song" "USR2"
main
As you can see, I trapped two custom user signals before the main function is
invoked. These are called from other scripts to refresh the bar. So in the
refresh function I unset the given variables to load them again and I also
want to kill the sleep process mentioned as // This in the code above.
However, the sleep process suddenly disappears when the signal is sent. Any ideas?
This is the output of pstree "$(pidof -x flexblocks)" when I run it outside
of the script:
flexblocks───sleep
And it is the output of the same commnad within the function of signal USR signals:
flexblocks---pstree
pgrep does not find any process named sleep when running inside the refresh function.